Motivation ● Do you remember how to “set” a data into Memcached? ● Do you know the way to investigate when there are evictions on Memcached?
“set” by telnet is difficult % telnet localhost 11211 ...Escape character is ‘^]’ set foo 0 0 3 Foo STORED get foo VALUE foo 0 3 Foo END
When evictions detected 1. `memcached-tool SERVER:PORT` to check in which class evictions are. 2. `stats cachedump CLASS NUM` via telnet to see keys and expiration time 3. `get KEY` to see data value 4. And so on. … Needs some efforts.
In “memcached-cli” ● Interactive, friendly Interface. ● So powerfull that it covers most commands of Memcached. ● Useful features for Ops and Admin.
Run “memcached-cli” // Interactive Mode % memcached-cli [localhost] Type '\h' or 'help' to show help. email@example.com:11211> \q // quit // Batch mode % memcached-cli get foo bar Key:foo Value:Foo Length:3B Flags:0 Key:bar Value:Bar Length:3B Flags:0
set, add, replace memcached@~> set foo Foo OK memcached@~> add foo Whooah! Failed to add item. KEY foo, VALUE Whooah! memcached@~> replace foo Hoohoo. OK memcached@~> get foo
value: Hoohoo. length: 7B
Other data manipulation commands ❏ append, prepend … add prefix/suffix to data ❏ cas … check-and-set for transaction ❏ touch … update expiration time ❏ incr, decr … add or reduce numeric data value ❏ delete … remove data
What is “stats” commands? ❏ Built-in Memcached commands to get server internal statistics ❏ stats … general statistics ❏ stats <args> … various stats ❏ settings … server settings ❏ items … number / eviction / expire, etc. ❏ slabs … chunk / page / memory used ❏ conns … state / peer addr of active connections ❏ cachedump … sample some data of a slab ❏ sizes … item count per size ※Hold Lock ❏ detail … get / hit / set / del stats per namespace
Other Commands & Features ❏ randomset … random data generator ❏ dump_all / restore_dump … dump / restore whole data in server ❏ call <command> [<args>] … execute any command to server ❏ Term::ReadLine … support command history
Conclusion Enjoy chatting to memcached by “memcached-cli” !!