-
I have a Is it possible that at expiration time I can make a database call compare the entry and if they are unchanged then I extend the expiry time? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is where If you do want to resurrect at eviction time then this can be achieved in a roundabout manner using a listener that reinserts the entry. The |
Beta Was this translation helpful? Give feedback.
This is where
refreshAfterWrite
is useful. If the entry is accessed after that duration, but before expiration, then an async refresh is performed. TheCacheLoader.reload(key, oldValue)
can load the new value, optionally returning the old one is desired. This is used to hide latency rather than allow popular entries to expire and cause requests to stall waiting for it to be loaded anew.If you do want to resurrect at eviction time then this can be achieved in a roundabout manner using a listener that reinserts the entry. The
Caffeine.removalListener
is called after the operation completes, so it could reinsert with a short race if a concurrent load happens concurrently. That minor problem…