Skip to content

Mutable Cache with Background Refreshes #520

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

You must be logged in to vote

A wrinkle, on cache miss, we do want to block the data stream pipeline to fetch the latest data from the central cache via the cache wrapper.

You can avoid blocking by using getIfPresent to obtain the entry or null. The asMap() view might also be helpful.

Our refresh support is intended to be used with expiration, e.g. to allow active content to stay fresh and inactive content to fade away. A full reload is best suited by a scheduled, period task.

The cache.get is an alias for Map.computeIfAbsent, so you can use that only when helpful for blocking calls.

I was originally planning on writing my own cache manager with each cache implemented as a loading cache, but then I noticed that it'…

Replies: 3 comments 16 replies

Comment options

You must be logged in to vote
12 replies
@r39132
Comment options

@ben-manes
Comment options

@r39132
Comment options

@ben-manes
Comment options

@r39132
Comment options

Answer selected by ben-manes
Comment options

You must be logged in to vote
2 replies
@ben-manes
Comment options

@r39132
Comment options

Comment options

You must be logged in to vote
2 replies
@ben-manes
Comment options

@r39132
Comment options

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