dcache
dcache copied to clipboard
Replace guava's ListanableFuture with j.u.c.CompletableFuture
Googls's guava library provides ListanableFuture - a building block for async processing. Starting from java8 j.u.c.CompletableFuture is available, which covers almost all use cases of ListanableFuture.
In order to solve this and truly remove almost all ListenableFutures, we would need to change our caches from Guava to Caffeine.
For more Information: Caffeine is the recommended successor library from Guava itself to improve caching speeds. See the official Guava Javadocs here
Caffeine's caches return CompletableFutures, which is the main reason why this is significant.
Furthermore Caffeine's caches are more performant than Guava's.
This comes with it's own set of challenges, as Guava and Caffeine share a very similar API syntax, however their internals can be a little different (mainly how Exceptions are handled in the async threads for the cache). In some cases this might lead to behavioural changes that we need to be careful of.
Yes, in general, we should switch to Caffeine. What ever we do it iterative or in a single step can be discussed.
One of the projects have a nice road map for migration
https://github.com/bitcoinj/bitcoinj/issues/2254
Funny enough, they have used my notes. The word is small 😎