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

使用@CacheRefresh注解,cacheType为Both时,每台机器都会去更新远程redis吗,机制是啥样的呢 #819

Open
zhaojinhua123 opened this issue Sep 21, 2023 · 1 comment

Comments

@zhaojinhua123
Copy link

还有@CacheUpdate与@CacheInvalidate注解,其他节点在收到消息后,会更新/删除远程redis缓存吗

@areyouok
Copy link
Collaborator

CacheRefresh是定期后台刷新,以免缓存过期的时候去数据库加载响应太慢。如果Cache类型是Remote或Both,有一个简单的分布式锁,只有一个机器会去执行刷新(以免给数据库造成压力)。如果是Both,其它(没抢到锁的)机器定期执行的时候会使用redis里面的数据替换本地cache的数据。这里没有通知机制。

Cache更新的时候,将其它机器的本地Cache失效,这个是2.7才支持的可选功能,只针对Both类型有效,默认没有开。打开需要设置(比如在yml中)broadcastChannel,并在Cached注解(手工构造时在QuickConfig类)上面设置syncLocal = true。

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

2 participants