Memcache command-line Operations

Source: Internet
Author: User
Tags memcached

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?
    1. telnet localhost 200001 #登陆
    2. Stats #查看状态
    3. Flush_all #清理
    4. Quit #退出

2. Another learning:

echo ' Flush_all ' | NC localhost 200001

3.

1. Data storage (assuming key is test,value to 12345)

  

[Plain]View PlainCopyprint?
    1. printf "set Test 0 0 5\r\n12345\r\n" | NC 127.0.0.1 200001
    2. STORED

2. Data retrieval (assuming key is test)

  

[Plain]View PlainCopyprint?
    1. printf "Get test\r\n" | NC 127.0.0.1 200001
    2. VALUE Test 0 5
    3. 12345
    4. 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?
    1. printf "DECR Test 3\r\n" | NC 127.0.0.1 200001
    2. 12343

5. Data deletion (assuming key is test)

  

[Plain]View PlainCopyprint?
    1. printf "Delete test\r\n" | NC 127.0.0.1 11211
    2. DELETED

6. View memcached Status

 

[Plain]View PlainCopyprint?
  1. printf "stats\r\n" | NC 127.0.0.1 200001
  2. STAT PID 3025
  3. STAT Uptime 4120500
  4. STAT Time 1228021767
  5. STAT version 1.2.6
  6. STAT Pointer_size 32
  7. STAT Rusage_user 433.463103
  8. STAT Rusage_system 1224.515845
  9. STAT Curr_items 1132460
  10. STAT Total_items 8980260
  11. STAT bytes 1895325386
  12. STAT curr_connections 252
  13. STAT total_connections 547850
  14. STAT Connection_structures 1189
  15. STAT Cmd_get 13619685
  16. STAT Cmd_set 8980260
  17. STAT get_hits 6851607
  18. STAT get_misses 6768078
  19. STAT Evictions 0
  20. STAT Bytes_read 160396238246
  21. STAT Bytes_written 260080686529
  22. STAT limit_maxbytes 2147483648
  23. STAT Threads 1
  24. END

7. Simulate top command to view memcached status:

  

[Plain]View PlainCopyprint?
      1. printf "stats\r\n" | NC 127.0.0.1 200001
      2. Or
      3. Watch "Echo Stats | NC 127.0.0.1 200001 "

Memcache command-line Operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.