Skip to content
Discussion options

You must be logged in to vote

The LoadingCache.refresh documentation states "Caches loaded by a {@link CacheLoader} will call {@link CacheLoader#reload}..." which is the common case, but it doesn't preclude caches built from an AsyncCacheLoader. Internally the implementations only call asyncReload and rely on the delegation chain to resolve to the implementation logic.

AsyncLoadingCache stores a future into the cache and has a synchronous() view for a LoadingCache. It uses a AsyncCacheLoader, but can be given a CacheLoader (a subtype) for user convenience if their logic is best expressed synchronously and redefines the delegation chain from asyncReload => asyncLoad to asyncReload => reload => load. You can implement o…

Replies: 1 comment 3 replies

Comment options

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

@NathanHazout
Comment options

@ben-manes
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