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

希望增加分页条数的缓存功能 #820

Open
OctoberSouth opened this issue Jun 11, 2024 · 5 comments
Open

希望增加分页条数的缓存功能 #820

OctoberSouth opened this issue Jun 11, 2024 · 5 comments

Comments

@OctoberSouth
Copy link

希望增加分页条数的缓存功能,如分页多传一个参数,以判断本条语句是否需要实时查询还是走缓存直接返回

@abel533
Copy link
Collaborator

abel533 commented Jun 11, 2024

支持MyBatis本身的一级缓存和二级缓存。

@trifolium-x
Copy link

@abel533 本身的一级缓存和二级缓存影响范围过大,集群环境下都是关闭缓存的,依然建议添加分页总数缓存的入口,或者直接提供Consumer接口也行,或提供接口让用户自定义缓存实现。

@trifolium-x
Copy link

现在我的做法是

boolean hasTotalCount = 缓存中是否有总数;
Pagehelper.startPage(xxx,xxx, !hasTotalCount);
if(!hasTotalCount){
   设置缓存(page.getTotlaCount());
}

@abel533
Copy link
Collaborator

abel533 commented Oct 10, 2024

@trifolium-x 可以考虑加个缓存接口。

你的做法中,缓存如何失效过期?

@trifolium-x
Copy link

建议分页总数缓存策略用户自定义,主要考虑到某些复杂sql查询非常慢,项目中目前使用用户+定时的方案策略,

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

No branches or pull requests

3 participants