22/08/2015 - LINUX, MAC, MEMCACHED
This tutorial shows us how to install and interact with memcached server in terminal. For more info, check cheat sheet and use phpMemcachedAdmin browser GUI.
sudo apt-get install php5 php5-dev php5-memcached memcached
sudo apt-get install memdump
echo "stats settings" | nc localhost 11211
ps -ef
watch "echo stats | nc 127.0.0.1 11211"
telnet 127.0.0.1 11211
Use stats items
to list all items and dump details of given item with stats cachedump 3 100
.
telnet 127.0.0.1 11211
stats items
STAT items:3:number 1
STAT items:3:age 498
STAT items:22:number 1
STAT items:22:age 498
END
# The first number after ‘items’ is the slab id. Request a cache dump for each slab id, with a limit for the max number of keys to dump
stats cachedump 3 100
ITEM views.decorators.cache.cache_header..cc7d9 [6 b; 1256056128 s]
END
stats cachedump 22 100
ITEM views.decorators.cache.cache_page..8427e [7736 b; 1256056128 s]
END
set my_key_name 0 86400 7 # Set with a "flag" of 0, a TTL of 86400 seconds and 7 bytes of data
inanzzz # Value to set is entered on a separate line. Length matches the number 7 above
get my_key_name # Get the key "my_key_name" from memcached and return "inanzzz"