Memcache is a very simple, distributed memory cache used widely with mysql and other databases. Often we want to inspect what is in memcache server on development environment. Here are some handy command which can be used in development environment. It may not be suitable for production environment with huge data. This article assumes that you have memcached running on local machine (Linux or Mac).

Create some test keys

This step is optional. We’ll create some test keys (600 seconds expiry). You can skip this if you already have data in memcache and don’t want to add test data to it.

Dumping all keys using slabs

Run the following command to dump upto 10000 keys values from all slabs. You can change 10000 to a higher value if needed. This also prints the expiry timestamp of the key. Note that in case if key never expires its value if less than memcache server start time (current time – up_time).