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

缓存 Null Value 时,是否默认添加 TTL #520

Open
rain7564 opened this issue Oct 10, 2020 · 0 comments
Open

缓存 Null Value 时,是否默认添加 TTL #520

rain7564 opened this issue Oct 10, 2020 · 0 comments

Comments

@rain7564
Copy link

老师,您好!这里有个问题想向您请教!

当缓存 null value 后,如果不主动失效该缓存,且未设置 ttl,那么该缓存的 value 将会一直是 null
针对该问题,请问是否有比较优雅的解决方案?

这里有一个思路,烦请您评估一下是否可行,谢谢!

如下:

如果创建缓存的时候,value 值为 null,且 cacheNullValue 等于 true,如果缓存没有设置 ttl,那该缓存对应的 value 就会一直都是 null。那么能不能在缓存 null value 时,默认添加 ttl,比如 300s,这样的话就可以在 300s 后重新去 db 获取最新数据。

如果可以在 @Cache 注解增加对应的配置,那就更完美了。

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

1 participant