Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fineday009 opened this issue Oct 27, 2020 · 3 comments
Open

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

fineday009 opened this issue Oct 27, 2020 · 3 comments

Comments

@fineday009
Copy link
Collaborator

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

@TommyLemon
Copy link
Collaborator

TommyLemon commented Oct 27, 2020

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

@fineday009
Copy link
Collaborator Author

fineday009 commented Oct 27, 2020

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

@TommyLemon
Copy link
Collaborator

TommyLemon commented Oct 30, 2020

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

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

No branches or pull requests

2 participants