利用shell命令操作Memcached
转自:http://blog.s135.com/post/384/
首先,需要了解Memcached协议,如果不清楚可参考《Memcached 协议中英文对照》。
1、数据存储(假设key为zhangyan,value为12345)
STORED
2、数据取回(假设key为zhangyan)
VALUE zhangyan 0 5
12345
END
3、数值增加1(假设key为zhangyan,并且value为正整数)
12346
4、数值减少3(假设key为zhangyan,并且value为正整数)
12343
5、数据删除(假设key为zhangyan)
DELETED
6、查看Memcached状态
STAT pid 3025
STATuptime4120500
STATtime1228021767
STATversion1.2.6
STATpointer_size32
STATrusage_user433.463103
STATrusage_system1224.515845
STATcurr_items1132460
STATtotal_items8980260
STATbytes1895325386
STATcurr_connections252
STATtotal_connections547850
STATconnection_structures1189
STATcmd_get13619685
STATcmd_set8980260
STATget_hits6851607
STATget_misses6768078
STATevictions0
STATbytes_read160396238246
STATbytes_written260080686529
STATlimit_maxbytes2147483648
STATthreads1
END
7、模拟top命令,查看Memcached状态:
或者