I have configured cache2K with a loader so keys not present in the cache will be retrieved from the backend datastore. My pattern when updating persisted values it to update the database first, and then the cache is updated asynchronously through a database change notification. Is there any way to prevent stale reads between the time from the database update and the cache is notified of the change?
I was thinking of a mechanism where the stale data is kept in cache, but was effectively expired / loaded the next time the entity was retrieved from cache. I want to keep the key in the cache but force a load when anyone attempts to access the value. I tried setting keepDataAfterExpired = true, however, it seems not to have any effect.