Tencent/APIJSON

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

fineday009 opened this issue · 3 comments

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

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

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缓存起来。这里有个疑问,如果查询的数据表中有更新或者插入,这个缓存其实是感知不到的吧,对于一些需要相对实时但又想缓存部分数据的场景,似乎这个缓存用处不大?

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