I'd like to have a cache that works like this:
(After a failed reload (case E), next request is handled following case C.)
(If case A ends in Exception, Exception is thrown)
Does anyone know an existing implementation, or will I have to implement it myself?
https://github.com/ben-manes/caffeine
Caffeine provides exactly the behavior I want out of the box using refreshAfterWrite
:
LoadingCache<K, V> cache = Caffeine.newBuilder()
.refreshAfterWrite(expireTime, timeUnit)
.maximumSize(maxCountOfItems)
.build(k->loader.load(k));