Looking for a long time today, how to see the value of Memcache directly in the server, to determine whether PHP Memcache has been written in the
Https://www.ttlsa.com/memcache/memcache-list-all-keys/This method is not only applicable to windowns cmd. Also applies to Linux command line operations, the following is the specific content
Today is doing a memcache session test, but in the process of testing, found that memcache there is no relatively simple way to directly like Redis, keys * List all session key, and according to key get corresponding session content , so, I began to look for information, most of the memcache are some of the common commands, but the list of key methods, but not much, so came to Google, found a foreign material
Specific content I applied in my test environment, the operation is as follows
1. cmd on login memcache
1 |
> telnet 127.0.0.1 11211 |
2. List all keys
1234 |
stats Items //This is an order . STAT Items:7:number 1 STAT items:7:age 188 END |
3. Get key via Itemid
Next, based on the items ID listed, this example is 7, the 2nd parameter is the length listed, and 0 is all listed
123 |
stats cachedump 7 0 // This is the command ITEM sess_sidsvpc1473t1np08qnkvhf6j2 [183 b 1394527347 s end |
4. Get the key value via get
The stats cachedump command above lists my session key, followed by a GET command to find the corresponding session value
1234567 |
get sess_sidsvpc1473t1np08qnkvhf6j2 //This is an order .VALUEsess_sidsvpc1473t1np08qnkvhf6j2 1440 1 the sess_| A:5:{s:6:; S:32: " E70981FD305170C41A5632B2A24BBCAA "; S:3: "UID" s:1: " s:8: "username" ; S:5: "admin" s:9: "logintime" ; S:19: 2014-03-11 16:24:25 "; S:7: "log Inip "; S:9:"127.0.0.1";} |
The above operation is directly copied, I test, no problem
http://blog.csdn.net/liu414226580/article/details/8263445 This method is the direct set, get.
1. A
[Plain]View PlainCopyprint?
- telnet localhost 200001 #登陆
- Stats #查看状态
- Flush_all #清理
- Quit #退出
2. Another learning:
echo ' Flush_all ' | NC localhost 200001
3.
1. Data storage (assuming key is test,value to 12345)
[Plain]View PlainCopyprint?
- printf "set Test 0 0 5\r\n12345\r\n" | NC 127.0.0.1 200001
- STORED
2. Data retrieval (assuming key is test)
[Plain]View PlainCopyprint?
- printf "Get test\r\n" | NC 127.0.0.1 200001
- VALUE Test 0 5
- 12345
- END
3. Increase the value by 1 (assuming that key is test and value is a positive integer)
printf "incr Test 1\r\n" | NC 127.0.0.1 200001
12346
4, the value is reduced by 3 (assuming that key is test and value is a positive integer)
[Plain]View PlainCopyprint?
- printf "DECR Test 3\r\n" | NC 127.0.0.1 200001
- 12343
5. Data deletion (assuming key is test)
[Plain]View PlainCopyprint?
- printf "Delete test\r\n" | NC 127.0.0.1 11211
- DELETED
6. View memcached Status
[Plain]View PlainCopyprint?
- printf "stats\r\n" | NC 127.0.0.1 200001
- STAT PID 3025
- STAT Uptime 4120500
- STAT Time 1228021767
- STAT version 1.2.6
- STAT Pointer_size 32
- STAT Rusage_user 433.463103
- STAT Rusage_system 1224.515845
- STAT Curr_items 1132460
- STAT Total_items 8980260
- STAT bytes 1895325386
- STAT curr_connections 252
- STAT total_connections 547850
- STAT Connection_structures 1189
- STAT Cmd_get 13619685
- STAT Cmd_set 8980260
- STAT get_hits 6851607
- STAT get_misses 6768078
- STAT Evictions 0
- STAT Bytes_read 160396238246
- STAT Bytes_written 260080686529
- STAT limit_maxbytes 2147483648
- STAT Threads 1
- END
7. Simulate top command to view memcached status:
[Plain]View PlainCopyprint?
- printf "stats\r\n" | NC 127.0.0.1 200001
- Or
- Watch "Echo Stats | NC 127.0.0.1 200001 "
Memcache command-line Operations