现在的位置: 首页shell>正文
利用shell命令操作Memcached
2012年01月17日 shell 评论数 1 ⁄ 被围观 11,108 次+

利用shell命令操作Memcached

数据存储(假设key为test,value为12345)

  1. printf "set test 0 0 5\r\n12345\r\n" | nc 127.0.0.1 12000  

STORED

数据取回(假设key为test)

  1. printf "get test\r\n" | nc 127.0.0.1 12000  

VALUE test 0 5

12345

END

数值增加1(假设key为test,并且value为正整数)

  1. printf "incr test 1\r\n" | nc 127.0.0.1 12000  

12346

数值减少3(假设key为test,并且value为正整数)

  1. printf "decr test 3\r\n" | nc 127.0.0.1 12000  

12343

数据删除(假设key为test)

  1. printf "delete test\r\n" | nc 127.0.0.1 12000  

DELETED

查看Memcached状态

  1. printf "stats\r\n" | nc 127.0.0.1 12000  

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

模拟top命令,查看Memcached状态:

  1. watch "printf 'stats\r\n' | nc 127.0.0.1 12000"  

或者

  1. watch "echo stats | nc 127.0.0.1 12000"  
本文地址:http://www.92csz.com/58/1030.html
如非注明则为本站原创文章,欢迎转载。转载请注明转载自:moon's blog
 

目前有 1 条留言 其中:访客:1 条, 博主:0 条

  1. 小张 : 2012年11月12日14:09:15  -49楼

    网站皮肤很好

    http://www.dflrpf.com