17

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.

5
  • For starters you need a Java-based memcached client; see stackoverflow.com/questions/731738/java-memcached-client
    – Dexygen
    Dec 7, 2011 at 18:54
  • Do you mean I can use client to view cached data inside memcache??
    – Mike
    Dec 7, 2011 at 19:02
  • A client would seem to me to be useless if you couldn't use it for that purpose. I would suggest you research then post a new question once you are using a client, if you continue to have problems.
    – Dexygen
    Dec 7, 2011 at 19:05
  • I've already installed memcache server & I just want to know if there is a way to see the cached data within it. Please see my updated edits.
    – Mike
    Dec 7, 2011 at 19:07

2 Answers 2

15

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
10

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}
1
  • 4
    The binary may be named memcdump instead of memdump on your distro. Feb 6, 2018 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.