Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the expire time for the particular item in memcached

In runtime, I want to retrieve the expire time info about some items in memcached. I didn't find any related interface on memcached. Can I do this? something like: mc.get_expire_time('key')

Thank you

like image 432
maguschen Avatar asked Apr 01 '10 07:04

maguschen


1 Answers

Python memcache API doesn't provide such functionalities. However you can telnet into memcached to dump all keys and expiration time.

> telnet localhost 11211

stats items show the slabs that contain your data.

stats items
STAT items:12:number 1108
...
END

Then use stats cachedump slab_id count to see the key and expiration time. Set count to 0 to retrieve all keys.

stats cachedump 12 1
ITEM abc [100 b; 1528336485 s]
END
like image 138
Ko-Chih Wu Avatar answered Sep 17 '22 15:09

Ko-Chih Wu