Understanding Memcached stats cachedump command

This is an undocumented feature, meaning this command is not supported by the Memcached team, it still exists in 1.4.5 but can possibly be removed in any version.

stats cachedump command

Telnet command : stats cachedump <slabs_id> <limit>\r\n

Parameters :

  • <slabs_id> : slab id from where you want to retreive the keys
  • <limit> : result limit, 0 mean no limit

Be aware that this function return is limited to 1MB (or maybe 2MB, this is not clear actually)

Example :

stats cachedump command return

It return items with the template
ITEM <item_key> [<item_size> b; <expiration_timestamp> s]

Parameters :

  • <item_key> : The item key
  • <item_size> : Item size (including key) in bytes
  • <expiration_timestamp> : Expiration timestamp in second

To understand the timestamp, we need to make a stats command on the server

If the timestamp is equal to stats(time – uptime) then the item have got an infinite expiration else the item will expire when the timestamp is reached.

In our example, 1293536562 – 4222347 = 1289314215, two items have an infinite expiration

Other Memcached Resources

You can find a lot of Memcached resources on this Memcached resources page.

1 Response

  1. Jim W Knoll says:

    Just wondering about the pitfalls. Seems like dump would be a desirable feature that would be good to support. Just want to understand the problems with this. Obviously, with its lack of support, it is or could become problematic.

    A prod use case would be allowing many writers to push data into the cash and allowing a console app to crape the status out without knowing all the keys.

Leave a Reply

Your email address will not be published. Required fields are marked *