memcached linux 下操作

telnet localhost 200001 #登陆

  stats #查看状态

  flush_all #清理

  quit #退出

 

------------------------------------------------

首先,需要了解Memcached协议,如果不清楚可参考《Memcached 协议中英文对照:http://bbs.chinaitlab.com/thread-308784-1-1.html》。

    1、数据存储(假设key为zhangyan,value为12345)

 

   

 printf "set zhangyan 0 0 5\r\n12345\r\n" | nc 127.0.0.1 11211

 

    STORED

 

    2、数据取回(假设key为zhangyan)

 

 

 printf "get zhangyan\r\n" | nc 127.0.0.1 11211

 

    VALUE zhangyan 0 5
     12345
     END

 

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

 

   

 printf "incr zhangyan 1\r\n" | nc 127.0.0.1 11211

 

    12346

 

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

 

 

 printf "decr zhangyan 3\r\n" | nc 127.0.0.1 11211

 

    12343

 

    5、数据删除(假设key为zhangyan)

 

   

 printf "delete zhangyan\r\n" | nc 127.0.0.1 11211

 

    DELETED

 

    6、查看Memcached状态

 

 

 printf "stats\r\n" | nc 127.0.0.1 11211

 

  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、模拟top命令,查看Memcached状态:

 

 

 watch "printf 'stats\r\n' | nc 127.0.0.1 11211"

  
  或者
  
 

 watch "echo stats | nc 127.0.0.1 11211"

 

转自:http://hi.baidu.com/gmail07/item/3974d60f7dbaa1e6f55ba625
http://www.bitscn.com/os/linux/200812/155768.html
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值