views:

1144

answers:

4

In the "Memcache Viewer", is there any way to dump a list of existing keys? Just for debugging, of course, not for use in any scripts!

I ask because it doesn't seem like the GAE SDK is using a "real" memcache server, so I'm guessing it's emulated in Python (for simplicity, as it's just a development server).. This would mean there is a dict somewhere with the keys/values..

+1  A: 

No. I did not found such functionality in memcached too.

Thinking about this issue, I found this limitation understandable - it would require keeping a registry of keys with all related problems like key expiration, invalidation and of course locking. Such system would not be as fast as memcaches are intended to be.

zgoda
Is the memcache client in the GAE dev-server actually connecting to a memcache server? Quickly looking at the code it almost seems like it's emulated in Python..?
dbr
To my best understanding it's indeed Google's own implementation that might be based on, but is certainly not memcache. It's using the memcache api though because it's easy and does the job well.
Koen Bok
A: 

Memcache is designed to be quick and there's no convincing use case for this functionality which would justify the overhead required for a command that is so at odds with the rest of memcached.

The GAE SDK is simulating memcached, so it doesn't offer this functionality either.

Andrew Wilkinson
This is incorrect. memcached most certainly holds all of your keys, flags, expiration, cas identifiers, and a few other things in memory. What it does not do is perform any options that cannot be executed in a known amount of time (O(1) -- such as listing all keys).
Dustin
You're quite right, the keys are hashed to determine which server to use but the original key is passed to the server rather than the hash as I originally though.
Andrew Wilkinson
+5  A: 

People ask for this on the memcached list a lot, sometimes with the same type of "just in case I want to look around to debug something" sentiment.

The best way to handle this is to know how you generate your keys, and just go look stuff up when you want to know what's stored for a given value.

If you have too many things using memcached to do that within the scope of your debugging session, then start logging access.

But keep in mind -- memcached is fast because it doesn't allow for such things in general. The community server does have limited functionality to get a subset of the keys available within a given slab class, but it's probably not what you really want, and hopefully google doesn't implement it in theirs. :)

Dustin
A: 

The easiest way that I could think of, would be to maintain a memcache key at a known ID, and then append to it every time you insert a new key. This way you could just query for the single key to get a list of existing keys.

LarryH