获取在memcached中设置的所有密钥 [英] get all keys set in memcached
问题描述
我尝试了谷歌搜索,但没有发现太多,除了 PHP
支持 getAllKeys code> method
,这意味着它实际上可以做到这一点。
那么,如何在telnet会话中获得相同的结果呢?
我试过了 memcached备忘单和 Memcached telnet命令摘要,但它们都不起作用,并且我无法找到正确的方法来完成此操作。
PS:我正在执行此操作在开发中,所以可以假定由于设置了新键或其他这样的竞争条件而不会有问题。
找到一种方法,感谢链接
a>(与原始的此处的Google小组讨论)首先, Telnet
到您的服务器:
telnet 127.0.0.1 11211
接下来,列出项目以获取slab ID:
stats项目
STAT项目:3:number 1
STAT项目:3:年龄498
STAT项目:22:号码1
STAT项目:22:年龄498
END
'items'之后的第一个数字是板ID。请求每个板块ID的缓存转储,并限制要转储的最大密钥数量:
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
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.
So, 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.
PS: 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.
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屋!