Skip to content
Discussion options

You must be logged in to vote

In v3.x it will only perform one refresh per key as it maintains a second mapping. In previous versions it couldn't dedupe on an explicit LoadingCache.refresh(key), only for implicit ones by refreshAfterWrite. If there is an explicit write, like put or remove, then the in-flight refresh for that key will be abandoned and discarded (this maintains linearizability).

If you want more control then you can coalesce, jitter, etc. by defining the asyncReload method. See this example which groups individual refreshes into a time/space window for a batch call. Since the cache has a handle to a future you can rate limit it, batch, retry and backoff, etc. as you see fit.

Hope that helped?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@carter-c-icap
Comment options

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