Clean cached data quickly #134
-
Hi, We are using cachelib in a storage system with RAFT consensus. We are thinking of a way to invalidate all cache items in the cache quickly on partition leader change, to avoid cache incoherence. Since it's leader change, the callback must finish quickly, maybe 1s. I am wondering whether cachelib can (1) support removing all keys in the cache with one function call (2) do this quickly. Our goal is just to make sure those keys are not found when calling cache.find(). It may be achieved by clearing all meta data or data in cachelib. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
The easiest way to do this would be to have an epoch for all the cache items that is bumped up on version change and let your application code do epoch checks after find() while having some background thread purge expired epochs or let them fall out of cache as the reads taper off. This does not accomplish your goal as you outline it above on how it can be done, but wonder if this meet the application level requirement to wipe out the cache. Few more questions
|
Beta Was this translation helpful? Give feedback.
-
if the intent is to drop all the cache at once on leader role change, have you tried doing cache reset and reinstantiating a new cache ? Can you stall reads briefly while the cache is being reset ? (assuming you will have to synchronize the cache instance in the call sites to pick up the right one with the concurrent purge) |
Beta Was this translation helpful? Give feedback.
if the intent is to drop all the cache at once on leader role change, have you tried doing cache reset and reinstantiating a new cache ? Can you stall reads briefly while the cache is being reset ? (assuming you will have to synchronize the cache instance in the call sites to pick up the right one with the concurrent purge)