Recommended way to pre-warm memcached?

Solution 1:

This would be very dependent on your application. memcached is simply a way to store values for some key in a non-persistent manner, and as such there's no real way to build a standardized script. It also does not have a way to browse current contents, so there's not a real way to save the contents before reboot.

If you're using some sort of application framework that internally tracks popularity, it may have some functionality to do this (this is unlikely). The best way to to actually prime memcached would be for a custom script to take appropriate things and push them into the store. However if you use expirations, not randomizing on this priming could create problems later when things expire at the same time. Alternately and assuming a web app, setting some sort of crawler loose doing a 2-3 link deep crawl may be effective. Not attempting priming of the cache and focusing on making non-cached requests respond reasonably fast would probably be a better use of resources than any of the above.

The real solution is to not reboot the server weekly. A properly running system should not require regular reboots (only reboot for very low level system patches).

Solution 2:

Perhaps look at migrating to a caching solution which persists to disk like Redis (http://code.google.com/p/redis/)

Solution 3:

If anyone is still interested in this, memcached now supports it https://github.com/memcached/memcached/wiki/ReleaseNotes1518