Testing memcached from command line
Tuesday, October 27th, 2009We use memcached to cache static or less dynamic content and use java client to communicate with memcached. Memcached is a simple but powerful cache server which sits out side of JVM. Since it sits out of JVM, a cluster of java servers can use single instance of memcached for storing content. Many argue that this will be single point of failure. But you can easily configure another memcached instance and configure the client to use it as failover (though you will loose all the cached objects if first server fails).
It is always good to test the server status & behavior through command line.
Assuming you have memcached server running on your localhost:11211, we can do following to check the statistics, a particular key, deleting a key, etc.,
$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
version
VERSION 1.2.2
stats
STAT pid 19516
STAT uptime 5897634
STAT time 1256702309
STAT version 1.2.2
STAT pointer_size 32
STAT rusage_user 91.789736
STAT rusage_system 124.147758
STAT curr_items 325
STAT total_items 13632131
STAT bytes 1449461
STAT curr_connections 11
STAT total_connections 1089
STAT connection_structures 12
STAT cmd_get 25936
STAT cmd_set 13632131
STAT get_hits 20400
STAT get_misses 5536
STAT evictions 0
STAT bytes_read 1056124842
STAT bytes_written 117570222
STAT limit_maxbytes 2147483648
STAT threads 1
get key AlreadyAddedKey.HelloWorld
VALUE AlreadyAddedKey.HelloWorld 0 33
http://www.avanathan.com
END
delete AlreadyAddedKey.HelloWorld
DELETED
delete NonExistingKey
NOT_FOUND
These few commands should should get you going.
For more details refer memcached protocol from Sixapart