List all objects in memcached

16917 views
Skip to first unread message

HE

unread,
Jul 16, 2008, 4:07:40 PM7/16/08
to memcached
Is there any way (a function maybe) to list all the objects that i
have on memcache?.
is there a way to see that?.

Emiliano J. Horcada

Josef Finsel

unread,
Jul 16, 2008, 4:27:12 PM7/16/08
to memc...@googlegroups.com
Nope.

Listing all of the objects in memcached would be very non-performant and would block updates and adds.  Why do you want to see the list?

Josef


"If you see a whole thing - it seems that it's always beautiful. Planets, lives... But up close a world's all dirt and rocks. And day to day, life's a hard job, you get tired, you lose the pattern."
Ursula K. Le Guin

HE

unread,
Jul 16, 2008, 4:32:55 PM7/16/08
to memcached
I have an aplication (not made by me) and i have to rewrite some parts
of the code, and it would come very handy to have the list of all the
objects in cache so i know how to call them without going through the
entire code looking for the name of each object.


On Jul 16, 5:27 pm, "Josef Finsel" <carpd...@gmail.com> wrote:
> Nope.
>
> Listing all of the objects in memcached would be very non-performant and
> would block updates and adds.  Why do you want to see the list?
>
> Josef
>
> "If you see a whole thing - it seems that it's always beautiful. Planets,
> lives... But up close a world's all dirt and rocks. And day to day, life's a
> hard job, you get tired, you lose the pattern."
> Ursula K. Le Guin
>

Ray Krueger

unread,
Jul 16, 2008, 4:38:51 PM7/16/08
to memc...@googlegroups.com
Turns out there's a great way to have a look see at that. Have a look
at mcinsight, it was mentioned a bit ago on this list...
http://groups.google.com/group/memcached/browse_thread/thread/d72ed6f616d88010

The code is out at:
http://github.com/andrewfromgeni/mcinsight/tree

I hope you have a mac handy :P

HE

unread,
Jul 16, 2008, 4:43:20 PM7/16/08
to memcached
Mmm sounds good, but didnt undestand how it works. Im still reading
though.
Dont have a mac :(


On Jul 16, 5:38 pm, "Ray Krueger" <raykrue...@gmail.com> wrote:
> Turns out there's a great way to have a look see at that. Have a look
> at mcinsight, it was mentioned a bit ago on this list...http://groups.google.com/group/memcached/browse_thread/thread/d72ed6f...
>
> The code is out at:http://github.com/andrewfromgeni/mcinsight/tree
>
> I hope you have a mac handy :P
>

Boris Partensky

unread,
Jul 16, 2008, 4:43:36 PM7/16/08
to memc...@googlegroups.com
By "name of each object" do you mean memcached key? IF you want to dump the keys once to see what they are,  you can use stats command. It is blocking and will take awhile, but this will serve your purpose I guess.
--
--Boris

HE

unread,
Jul 16, 2008, 4:45:25 PM7/16/08
to memcached
ok, how can i do that?

On Jul 16, 5:43 pm, "Boris Partensky" <boris.parten...@gmail.com>
wrote:

dormando

unread,
Jul 16, 2008, 4:50:46 PM7/16/08
to memcached
That doesn't list all keys, it lists a subset.

HE; what you should probably do is write a wrapper around the original
application's memcached get/set/etc commands and have it log the keys its
using. Then use that log to interact with the application.

-Dormando

Boris Partensky

unread,
Jul 16, 2008, 5:47:02 PM7/16/08
to memc...@googlegroups.com
Ok, you need to use a combination of  "stats items" and "stats cachedump" commands.
Basically, stats items spits out stats for each slab class. Part of that stats is slab class id, which (along with limit number) you need to pass to "stats cachedump".
Of course you need to do it on every server. Alternatively, if you use java whalin client, it kind of supports it already, you just need to call statsItems, parse out slab id and call statsCacheDump (or something like this, check out this link http://www.google.com/codesearch?hl=en&q=memcached+stats+lang:java+show:cM-7xUSBekQ:c3tBZDsv1vE:cM-7xUSBekQ&sa=N&cd=1&ct=rc&cs_p=http://memcachedtest.googlecode.com/svn&cs_f=src/org/memcached/Test.java).
 Here is what I just did on my dev machine and got some keys listed:

marfa:~ boris$ nc localhost 11211
stats items
STAT items:1:number 53
STAT items:1:age 91710
STAT items:2:number 61
STAT items:2:age 91710
STAT items:3:number 6
STAT items:3:age 76285
STAT items:13:number 2
STAT items:13:age 91710
STAT items:14:number 9
STAT items:14:age 76938
STAT items:15:number 8
STAT items:15:age 76302
STAT items:16:number 2
STAT items:16:age 76264
END
stats cachedump 15 100
ITEM UserMemcache_0_19680722 [2036 b; 1216152837 s]
ITEM UserMemcache_0_19680718 [1790 b; 1216152837 s]
ITEM UserMemcache_0_19680717 [1790 b; 1216152837 s]
ITEM UserMemcache_0_19680719 [1790 b; 1216152837 s]
ITEM UserMemcache_0_19680707 [1786 b; 1216152837 s]
ITEM UserMemcache_0_19680708 [2020 b; 1216152837 s]
ITEM UserMemcache_0_19680709 [1833 b; 1216152837 s]
ITEM UserMemcache_0_19680706 [1922 b; 1216152837 s]
END
--
--Boris

dormando

unread,
Jul 16, 2008, 8:14:49 PM7/16/08
to memc...@googlegroups.com
That does not list all keys. It lists keys up to a certain buffer size (a
meg?).
It's also a really horrible habit to get into in case you end up relying
on this and roll into production.

-Dormando

Boris Partensky

unread,
Jul 16, 2008, 11:52:17 PM7/16/08
to memc...@googlegroups.com
Clearly. But I think he just wanted to get a sense of what current cache looks like.
--
--Boris

Ludovic Levesque

unread,
Jul 17, 2008, 2:05:03 AM7/17/08
to memc...@googlegroups.com
Hi,

I just copy an older message I posted one day on list:

you can have a little data usage report sniffing the network:
ngrep -W none -T -d any "^(get|set|delete|END|STORED|VALUE|DELETED)"
port 11211 | awk '{print $1 " " $2}'

or without the awk.

It's just plain keys and return values, but it can be useful to have a
look at what is used in cache.

Hope it helps
Ludovic

HE

unread,
Jul 17, 2008, 8:10:28 AM7/17/08
to memcached
Thanx to everyone.
There are a lot of good answers.
I guess im going to do a log to the aplication so i can read the keys
an time they where made on. It´s what i nead.
Thank again everyone.

HE

On Jul 17, 3:05 am, "Ludovic Levesque" <lud...@gmail.com> wrote:
> Hi,
>
> I just copy an older message I posted one day on list:
>
> you can have a little data usage report sniffing the network:
> ngrep -W none -T -d any "^(get|set|delete|END|STORED|VALUE|DELETED)"
> port 11211 | awk '{print $1 " " $2}'
>
> or without the awk.
>
> It's just plain keys and return values, but it can be useful to have a
> look at what is used in cache.
>
> Hope it helps
> Ludovic
>
Reply all
Reply to author
Forward
0 new messages