I use Caffeine cache to cache data coming from the DB that need to served to a rest endpoint. So the cache is updated ONLY on read operations on the DB.
In the nominal case, I want the cache to take the lead of responding until the data is not older than some point of time ( => this case is ok by defining the correct expiration options)
In case of DB access failure, I want to fallback to the cache even if the data in the cache is expired. This use case supposes that expired data are not yet removed.
The solution I'm thinking of is to make Eviction of Items from the cache only after a successful PUT
(a successful PUT means the DB is working correctly).
Is that possible to do?