![]() |
|
|
Memcached Cheat SheetI use Memcached as a back-end cache for a lot of my PHP projects. The performance is great, but the administration tools leave something to be desired. I've compiled a short list of common administrative commands that I find useful. Unless otherwise noted, these commands are typed into the server via its network interface: telnet <servername or localhost> 11211 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. <enter commands here> Flushing the CacheThis will mark all entries as expired, but does not purge them. (As far as I can tell, you can't.) They won't be returned any longer however, and will be replaced as space is needed. flush_all You'll get an "OK" response back. Viewing all Cache EntriesThere's no easy way to view all entries in the cache, but you can use this method to sample the entries. First you need to find the slab IDs that are in use using "stats items": stats items STAT items:1:number 2361 STAT items:1:age 1752296 STAT items:1:evicted 0 STAT items:1:evicted_nonzero 0 STAT items:1:evicted_time 0 STAT items:1:outofmemory 0 STAT items:1:tailrepairs 0 STAT items:1:reclaimed 1 STAT items:2:number 8417 <snip> The slab IDs are the numbers right after "items:". In this example 1 and 2 (actual numbers on this instance went to 31.) Now we can look at the entries in each slab with the command "stats cachedump <slab id> <number to show>": stats cachedump 1 10 ITEM blah_47711_namespace_key [4 b; 1324997985 s] ITEM blah_48379_namespace_key [4 b; 1324997985 s] ITEM blah_48465_namespace_key [4 b; 1324997985 s] ITEM blah_51403_namespace_key [4 b; 1324997985 s] <snip> You'll have to run through the various slabs one at a time to see all the entries. Exiting the Command Shellquit Connection closed by foreign host. |