Skip to content
Discussion options

You must be logged in to vote

CompletableFuture uses a stack of dependent actions so your own action is run prior to Caffeine receiving a callback. We have to return the computed future, not the dependent action's, for the asMap() view (reference identity, e.g. replace) and since methods like cancel() do not communicate. That means we really can do anything in the implementation.

You could perform an explicit remove in your own callback, e.g. cache.asMap().remove(key, future), prior to a retry. Or you could return a future that already handles the retry internally (e.g. failsafe example). I usually use .executor(Runnable::run) in tests to disable asynchronous processing unless I am testing for concurrent executions.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@benjaminp
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