[rails-oceania] Memcache key and value?

19 views
Skip to first unread message

Denny

unread,
Aug 22, 2011, 4:16:02 AM8/22/11
to rails-...@googlegroups.com
Hi, all

   As we all know, we can use cache in our application. Here is question:

How can I get all the key and value in memcache database?

1. in console, do we have a method to list all?
2. can we directly visit memcache database for this?

-- 
Denny
Sent with Sparrow

Matt Allen

unread,
Aug 22, 2011, 6:02:44 AM8/22/11
to rails-...@googlegroups.com
Hi Denny;

You can't. Generally you'll be using some sort of known, reproducible composite key to retrieve the data you need.

An example of this that i've used in the past for some fragment caching is a combination of model class name + id or controller name + model + id.

Hope that helps,
Matta

> --
> You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group.
> To post to this group, send email to rails-...@googlegroups.com.
> To unsubscribe from this group, send email to rails-oceani...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.

Nathan de Vries

unread,
Aug 22, 2011, 9:08:29 AM8/22/11
to rails-...@googlegroups.com
While Matt is correct that memcached should be treated as a black box, it's actually quite feasible (and reasonable!) to want to look at what it's storing. You'll often need this during development, but also on occasion when a live server is running amok.

There's a couple of tools you'll want to check out:


The former attaches to a running process, freezes it, inspects the key metadata, and returns the process to a running state (via dtrace). It's suitable for use in development & production.

The latter acts as a proxy for your memcached server and captures keys data on the way through. It's really only something you'd want to use in development.


Cheers,

Nathan de Vries

Matt Allen

unread,
Aug 22, 2011, 7:40:54 PM8/22/11
to rails-...@googlegroups.com
Hey Denny and Nath;

The other thing you'd do in dev mode, is to run it in non-daemon mode with -v and it'll spit out all the logging. That'll include hits, misses and keys.

Matta

Martin Stannard

unread,
Aug 22, 2011, 10:20:00 PM8/22/11
to rails-...@googlegroups.com
Hey guys,

For high level stats I only just found out about

memcached-tool localhost stats

and have found it very useful for getting an overview of cache usage.

regards,

Martin

Ben Schwarz

unread,
Aug 23, 2011, 8:18:42 PM8/23/11
to rails-...@googlegroups.com
I wrote amnesia (a memcached web stat page) a while ago, not really what you're looking for, but I'm sure it could be extended pretty easily. 

Denny

unread,
Aug 27, 2011, 11:38:13 PM8/27/11
to rails-...@googlegroups.com
Thanks, your guys.

Why I need these keys in development?

I maintained the code from other, and not sure which cache is used now, so I need the cache key list, and check it in code, or maybe I can remove some cache code.

@Ben, I will check your amnesia, thanks!
@Nathan, thanks! 


-- 
Denny
Sent with Sparrow

On Wednesday, August 24, 2011 at 8:18 AM, Ben Schwarz wrote:

I wrote amnesia (a memcached web stat page) a while ago, not really what you're looking for, but I'm sure it could be extended pretty easily. 

--
You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rails-oceania/-/_6FyzqnkrUcJ.
Reply all
Reply to author
Forward
0 new messages