Replies: 1 comment 2 replies
-
It is best to think of Caffeine as a
Note that CompletableFuture#cancel does not send an interrupt signal to the underlying thread, and merely terminates the future and its dependents as canceled. If the expensive operation has not yet started then it won't, but if it has then it will continue unabated.
Nope, it is the same as
The cache always returns the future it was given by the loader and does not provide any proxy. This is because operations like cancel don't propagate upstream and the lack of equality means that atomic action like
It sounds like you probably want something custom. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am considering using Caffeine in my application as a replacement for a home-made feature. I am not too much interested by the cache eviction features, but more by the concurrent async loading from expensive operations.
For my use case, I would like to be able to cancel the queued/running expensive operation after receiving some event telling that the computation inputs might be outdated (I say "might", because we don't really know what input was used by the computation job, as it is async).
Something like:
Thread1:
Thread2 (while thread 1 is blocked on
the future.get()
)Will a call to
invalidate
cancel the CompletableFuture previously obtained?In fact, what would really allow me to replace my current component would be if the asyncCache would be able to "substitute" the CompletableFuture so that it ultimately completes with a second call to the expensive operation. From Thread1 point of view, it would be totally transparent.
Is that possible?
Beta Was this translation helpful? Give feedback.
All reactions