2013/03/27

memcached 常用指令

Telnet command

> set foo 0 60 3
bar
STORED


> get foo
VALUE foo 0 3
bar
END
add, replace 與 set 的用法一樣,只是 add 遇到 key 已經存在則 return error,replace 遇到 key 不存在則 return error。


> delete foo
DELETED


> flush_all
OK


> stats
STAT pid 30845
STAT uptime 427550
STAT time 1363069077
STAT version 1.4.6
STAT libevent 2.0.7-rc
STAT pointer_size 64
STAT rusage_user 0.068989
STAT rusage_system 0.086986
STAT curr_connections 5
STAT total_connections 506
STAT connection_structures 7
STAT cmd_get 10
STAT cmd_set 19
STAT cmd_flush 1
STAT get_hits 8
STAT get_misses 2
STAT delete_misses 1
STAT delete_hits 1
STAT incr_misses 0
STAT incr_hits 0


> stats slabs
STAT 1:chunk_size 96
STAT 1:chunks_per_page 10922
STAT 1:total_pages 1
STAT 1:total_chunks 10922
STAT 1:used_chunks 9442
STAT 1:free_chunks 490
STAT 1:free_chunks_end 990
STAT 1:mem_requested 875108
STAT 1:get_hits 5987916
STAT 1:cmd_set 182569
STAT 1:delete_hits 16
STAT 1:incr_hits 0
STAT 1:decr_hits 0
STAT 1:cas_hits 0
STAT 1:cas_badval 0
STAT 2:chunk_size 120
STAT 2:chunks_per_page 8738
STAT 2:total_pages 2


> stats cachedump 1 1000
ITEM test1 [133 b; 1352958262 s]
ITEM test2 [10 b; 1352958262 s]
ITEM test3 [10 b; 1352958262 s]
ITEM test4 [15 b; 1352958262 s]
ITEM test5 [11 b; 1352958262 s]



內建的 tool

Show states
$ memstat --servers=localhost
         pid: 7848
         uptime: 11912375
         time: 1364870637
         version: 1.4.6
         libevent: 2.0.7-rc
         pointer_size: 64
         rusage_user: 1193.212604
         rusage_system: 4398.974254
         curr_connections: 184
         total_connections: 930825
         connection_structures: 249
         cmd_get: 168874575
         cmd_set: 6459571
         cmd_flush: 0
         get_hits: 158956302
         get_misses: 9918273
         delete_misses: 1
         delete_hits: 401
         ...

Dump all keys
$ memdump --servers='localhost'
KEY1
KEY2
...

Cat a set of key values
$ memcat --servers='localhost' TEST --verbose
key: TEST
flags: 0
length: 3
value: 123

How to dump memcache key/value pairs fast - dump the key values in parallel mode


Copy a set of files to a memcached.
The key names will be the names of the files, without any directory path.
$ ls
test.1   test.2   test.3
$ memcp --servers='localhost' test.*
$ memdump --servers='localhost'
test.1
test.2
test.3


沒有留言:

張貼留言