Skip to content

想问下cache的部分基于什么实现的? #146

Open

Description

@fineday009

是基于mysql的query_cache机制吗? 还是什么,有具体的原理没?

Activity

  1. TommyLemon commented on Oct 27, 2020

    @TommyLemon
    Member

    SQLExecutor:
    Map<String, List<JSONObject>> cache;
    void putCache(String sql, List<JSONObject> list, int type)
    List<JSONObject> getCache(String sql, int type)
    void removeCache(String sql, int type)
    https://github.com/APIJSON/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/orm/SQLExecutor.java
    image

  2. fineday009 commented on Oct 27, 2020

    @fineday009
    ContributorAuthor

    SQLExecutor:
    Map<String, List> cache;
    void putCache(String sql, List list, int type)
    List getCache(String sql, int type)
    void removeCache(String sql, int type)
    https://github.com/APIJSON/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/orm/SQLExecutor.java
    image

    感谢作者的回答!
    简单看了下实现逻辑,是将查到的List缓存起来。这里有个疑问,如果查询的数据表中有更新或者插入,这个缓存其实是感知不到的吧,对于一些需要相对实时但又想缓存部分数据的场景,似乎这个缓存用处不大?

  3. TommyLemon commented on Oct 30, 2020

    @TommyLemon
    Member

    这只是单次会话的缓存,用完即清,不需要感知更新。需要全局的可以重写相关方法,用 Redis 等方案存取

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions