memcached 查看方法
格式: telnet ip port
例如 telnet localhost 11211
退出命令:quit
一.存储命令
存储命令格式:
参数说明:
command name | 命令名称 |
key | 查找关键字 |
flag | 存储额外信息 |
expire | 数据保存时间,0表示永远,单位秒 |
bytes | 存储数据的字节数 |
data block | 存储的数据 |
1.set 无论如何都存储,数据不存在时存储,数据存在时更新。
2.add 当数据不存在时存储。
3.replace 当数据存在时存储
二.读取命令
1.get key 可以一个或多个,用空格格开。
2.gets 与 get 一样,但会返回多一个数字,这个数字用来检查数据是否被修改过,如修改过,这个数字回改变。
3.cas cas即checked and set ,当最后一个参数与gets返回的数字一致时才存储,否则返回EXISTS。
三.追加与清除命令
1.append 将数据追加到当前缓存数据的之后,当缓存数据存在时才存储。
2.prepend 将数据追加到当前缓存数据的之前,当缓存数据存在时才存储。
3.delete 删除缓存数据,数据存在返回DELETED,数据不存在返回NOT_FOUND
4.flush_all 将当前所有缓存数据设置为过期,但不会释放内存。四.状态命令
1.stats 查看memcached运行状态
2.stats items
执行stats items,可以看到STAT items行,如果memcached存储内容很多,那么这里也会列出很多的STAT items行。
3.stats cachedump slabs_id limit_num
slabs_id:由stats items返回的结果(STAT items后面的数字)决定的
limit_num:返回的记录数,0表示返回所有记录
通过stats items、stats cachedump slab_id limit_num配合get命令可以遍历memcached的记录。
4.stats slabs 显示各个slab的信息,包括chunk的大小、数目、使用情况等
5.stats sizes 输出所有item的大小和个数
6.stats reset 清空统计数据