获取在 memcached 中设置的所有键 [英] get all keys set in memcached
问题描述
如何获取我的 memcached 实例中设置的所有键?
我尝试谷歌搜索,但除了 PHP
支持 getAllKeys
方法,这意味着实际上可以以某种方式执行此操作.如何在 telnet 会话中获得相同的结果?
我已经尝试了 memcached 备忘单 和 Memcached telnet 命令摘要,但没有一个工作,我不知所措,找不到正确的方法来做到这一点.
注意:我目前正在开发中,因此可以假设不会因设置新密钥或其他此类竞争条件而出现问题,并且密钥数量也将受到限制.
首先,Telnet
到您的服务器:
telnet 127.0.0.1 11211
接下来,列出获取slab id的项目:
<前>统计项目STAT 项目:3:数量 1统计项目:3:年龄 498STAT 项目:22:编号 1统计项目:22:年龄 498结尾‘items’之后的第一个数字是slab id.为每个 Slab id 请求缓存转储,并限制要转储的最大键数:
<前>统计缓存转储 3 100ITEM views.decorators.cache.cache_header..cc7d9 [6 b;1256056128秒】结尾统计缓存转储 22 100ITEM views.decorators.cache.cache_page..8427e [7736 b;1256056128秒】结尾How can I get all the keys set in my memcached instance(s)?
I tried googling, but didn't find much except that PHP
supports a getAllKeys
method, which means it is actually possible to do this somehow. How can I get the same within a telnet session?
I have tried out all the retrieval related options mentioned in memcached cheat sheet and Memcached telnet command summary, but none of them work and I am at a loss to find the correct way to do this.
Note: I am currently doing this in development, so it can be assumed that there will be no issues due to new keys being set or other such race conditions happening, and the number of keys will also be limited.
Found a way, thanks to the link here (with the original google group discussion here)
First, Telnet
to your server:
telnet 127.0.0.1 11211
Next, list the items to get the slab ids:
stats items STAT items:3:number 1 STAT items:3:age 498 STAT items:22:number 1 STAT items:22:age 498 END
The first number after ‘items’ is the slab id. Request a cache dump for each slab id, with a limit for the max number of keys to dump:
stats cachedump 3 100 ITEM views.decorators.cache.cache_header..cc7d9 [6 b; 1256056128 s] END stats cachedump 22 100 ITEM views.decorators.cache.cache_page..8427e [7736 b; 1256056128 s] END
这篇关于获取在 memcached 中设置的所有键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!