[文章作者:张宴 本文版本:v1.0 最后修改:2008.11.30 转载请注明原文链接:http://blog.zyan.cc/post/384/]

  首先,需要了解Memcached协议,如果不清楚可参考《Memcached 协议中英文对照》。

  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"





技术大类 » Cache与存储 | 评论(52) | 引用(0) | 阅读(76238)
shzz Email
2022-8-24 02:58
Really impressive post. I read it whole and going to share it with my social circules. I enjoyed your article and planning to rewrite it on my own blog.  Team National
shz Email
2022-8-24 02:59
This post is good enough to make somebody understand this amazing thing, and I’m sure everyone will appreciate this interesting things.  Click Earners
shzz Email
2022-8-24 03:01
There's no doubt i would fully rate it after i read what is the idea about this article. You did a nice job..  Team National
shz Email
2022-8-24 03:03
Wonderful illustrated information. I thank you about that. No doubt it will be very useful for my future projects. Would like to see some other posts on the same subject!  Click Earners
shzz Email
2022-8-24 03:04
Cool stuff you have and you keep overhaul every one of us  Wesley Virgin
shzz Email
2022-8-24 03:07
It's really nice and meanful. it's really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull information.  Wesley Virgin
shz Email
2022-8-24 03:09
This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..  Click Earners
shzz Email
2022-8-24 03:10
I found Hubwit as a transparent s ite, a social hub which is a conglomerate of Buyers and Sellers who are ready to offer online digital consultancy at decent cost.  Wesley Virgin
shz Email
2022-8-24 03:12
I am impressed by the information that you have on this blog. It shows how well you understand this subject.  Click Earners
jim Email
2022-11-7 17:42
Cloud DevOps solutions instruments and principles are crucial for companies that want to rationalize the development and deployment process to hasten innovation.  cloud devops services
Lucky cola
2024-2-7 15:07
Experience adrenaline-pumping action in every game.  Lucky cola
分页: 3/3 第一页 上页 1 2 3 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]