dcache icon indicating copy to clipboard operation
dcache copied to clipboard

Replace guava's ListanableFuture with j.u.c.CompletableFuture

Open kofemann opened this issue 7 years ago • 3 comments
trafficstars

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.

kofemann avatar Aug 05 '18 11:08 kofemann

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.

LukasMansour avatar Mar 07 '23 07:03 LukasMansour

Yes, in general, we should switch to Caffeine. What ever we do it iterative or in a single step can be discussed.

kofemann avatar Mar 07 '23 09:03 kofemann

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 😎

kofemann avatar Mar 17 '23 23:03 kofemann