Skip to content

Possible to have a cache entry auto refresh after it expires? #897

Answered by ben-manes
brent-holland asked this question in Q&A
Discussion options

You must be logged in to vote

A periodic task that reloads the entries is simple and explicit so that is a common solution. Otherwise someone might have conditions (e.g. only reload for a subset) so then a predicate is needed to test with. That becomes a slippery slope of configuration bits that can be harder to understand and debug. A task that reloads all of the contents or loops over the asMap() view for a partial reload is more explicit and could bulk load the entries instead of doing them one-by-one.

To do what you are asking for, though, you might try using a removal listener to repopulate the cache when the cause is "expired". If you set a scheduler then it will be notified promptly rather than piggybacking on …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ben-manes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants