Thursday, August 28. 2008Dumping MemcacheD Content (Keys) with PHPTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
This does not work for large instances! You get only 1 or 2MB of keys per Slab! This is a hardcoded limit of the listbuffer in the C-Sourcecode!
How do i run into that limit? I am just querying the contents, right? Can you explain more?
This is correct. Looking at the source for memcached (1.4.2) in file items.c, function do_item_cachedump() contains a memlimit variable of: 2 * 1024 * 1024; /* 2MB max response size */
That appears to be the response size limit for cachedump commands. It does seem like one could simply increase that limit, however, the implications of making that change are unclear.
Ok, so 2 MB of keys per Slab? That looks like enough for me. Actually i have used this a lot and did not hit such a limit, i.e. always found the keys i was looking for. But good to know that this might have an impact.
hi. i'm getting
[Tue Dec 22 12:45:07 2009] [error] [client 127.0.0.1] PHP Notice: MemcachePool::getextendedstats() [memcachepool.getextendedstats]: Server localhost (tcp 11211, udp 0) failed with: CLIENT_ERROR bad command linern (0) in /usr/local/www/hullywood/html/test/get_mcache.php on line 15 error with it
There have been changes to the Memcache Ext with version 3 of it. see also:
http://drupal.org/node/366184 (scroll down to the later posts) But still: The calls to getExtendedStats in my code snippet should be still supported with the new Ext, but i am not 100% sure about that (didnt test). Downgrading the ext to 2.x should help, while i dont like downgrading in general. You could also examine which call to getExtendedStatus gives the error and try to figure out if and why it is not supported anymore.
already got it
just added is_numeric check for that new keys like that: foreach($allSlabs as $server => $slabs) { foreach($slabs AS $slabId => $slabMeta) { if (!is_numeric($slabId)) { continue; } and all went fine
Great. Cool site, btw. (dont understand a single word, but flash animations are nice)
Thanks a lot mate,
We only use memcached in small setups (single websever for mostly common/normal websites) with multiple webapps on 1 server. I was using a prefix for the keys to make sure that 2 webapps don't overwrite eachothers data and so I could just run with 1 memcached deamon. Now I wanted something to 'flush' only the keys for 1 webapp and with your lovely script I can now loop through the keys and delete the ones with the sites prefix.
Thanks for this good code. but when goes on dumping it flushes all the keys. is their any way so that while debugging keys still stay on cache.
Please I really need this debugging without flushing anything thing.
Well, for me it did not remove the keys. Memcache will, however, show also keys that are already expired. They will disappear when you try to read them. Maybe this is what you are experiencing?
Yes. I thought that they are clearing. but I think you are correct they are not flushing anything. few more thing from your code. is that possible for you to explain more about [ 'detail' => $eData, ] what it will contain.
And can we able to show what particular key have been hits. if you show me this then I will really really thanks for it.
Well, but the code is incorrect. "server" variable is repeated_in line 4 and line 7 and "server" of the line 7 overwrites line 4.
Second "server" variable is not a "server:port" and the "age" not works. Tested on memcache 1.2.6. Vins.
Hi Vins,
thanks for your reply. $server in line 4 is not needed. It is true that it is not good style to have it overwritten in line 7, but it works What do you mean with "server:port"? Age works for me. Gaylord
Hello Gaylorf....
For us It does not work. Our version for memcache 1.2.6: |
Calendar
QuicksearchArchivesCategoriesBlog AdministrationArchivesTop ReferrersChoose Language |
|||||||||||||||||||||||||||||||||||||||||||||||||

