memcachedpython-memcached

How to find the keys being evicted from memcache?


Is there any inbuilt way/ or a hack by which I can know which key is being evicted from memcache ?

There is one solution of polling for all possible keys inserted into memcache (e.g. get multi), but that is inefficient and certainly not implementable for large number of keys.

The functionality is not needed to be run in production, but during some benchmarking and optimization runs.


Solution

  • Not possible AFAIK, but a really good (and simple) solution is to modify your memcached library and do a print (or whatever you want) in the delete and multidelete methods. You can then get the keys that are being deleted (both by your app and by the library itself). I hope that helps