memcache dump and load

Steven Grimm sgrimm at
Thu Apr 12 22:32:33 UTC 2007

"Smaller" is the key there -- "stats cachedump" will dump a *portion* of 
the cache, or rather will dump up to a maximum amount of data. If your 
cache is small you'll likely get the whole thing, but if you have a 
multi-gigabyte cache you'll get a tiny fraction of the total.

Also (though this is perhaps not an issue in the "I'm about to upgrade" 
case) keep in mind that it locks the whole cache while it runs. No other 
client requests will be processed while the server is composing its 
response, which can take a while.


Paul Lindner wrote:
> So, I was poking through the code and came across two little gems,
> "stats items" and "stats cachedump".  That got me thinking about how
> to solve a common problem, which is cold caches when upgrading.
> So I wrote up and committed some modifications to memcached-tool that
> should help.
> Basically here's what you do:
>   memcached-tool host:port dump > /tmp/keys
>   # upgrade cache
>   nc host:port < /tmp/keys
> The script writes out memcache protocal with add statements, so if you
> app writes a key the old value won't overwrite it.
> I just threw this together in the past hour, so it has some rough
> edges and can be improved in a lot of ways.  Anyone want to give it a
> try?  You can find it here:
> I was able to dump and reload some of our smaller production caches
> and it seems okay.

More information about the memcached mailing list