How do I view the data in memcache?

此生再无相见时 提交于 2020-01-03 07:44:50

问题


I've installed memcache and now how do I really view the data in memcache?

Is there any way to see the data present in cache inside memcache?

How do I really know whether memcache is getting data stored inside it?

Note: I don't want to write any program to see the data inside memcache. Basically, memcache server is already installed in my environment and it is caching the data as well. But I would like to know if there are any utility programs available which will show me the cached data inside memcache or if there is any command which will show me the data cached so far.


回答1:


There is no way to get memcached to report which keys it holds. I believe that this was a design choice as to do so would have a negative impact on performance.

However, you can use any telnet client application to connect the memcached server and type in commands. Doing this to get or set a particular key.

For example,

stats

or:

get MY_KEY



回答2:


To dump a list of keys from a server, use memdump tool (sometimes memcdump), e.g.

memdump --servers=localhost

To get value of item, use netcat:

echo "get 13456_-cache-some_object" | nc 127.0.0.1 11211

or in Bash:

exec {memcache}<>/dev/tcp/localhost/11211; printf "get items:42:number\nquit\n" >&${memcache}; cat <&${memcache}

To dump all objects:

memdump --servers=localhost | xargs -L1 -I% sh -c 'echo "get %" | nc localhost 11211'

or in Bash:

exec {memcache}<>/dev/tcp/localhost/11211; printf "stats items\nquit\n" >&${memcache}; cat <&${memcache}


来源:https://stackoverflow.com/questions/8420776/how-do-i-view-the-data-in-memcache

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!