Skip to content

Instantly share code, notes, and snippets.

@munro
Created July 18, 2011 19:26
Show Gist options
  • Save munro/1090399 to your computer and use it in GitHub Desktop.
Save munro/1090399 to your computer and use it in GitHub Desktop.
dump memcache
<?php
$memcache = new Memcache;
$memcache->connect("localhost", 11211);
$memcache->flush();
$list = array();
$allSlabs = $memcache->getExtendedStats('slabs');
$items = $memcache->getExtendedStats('items');
foreach($allSlabs as $server => $slabs) {
foreach($slabs AS $slabId => $slabMeta) {
$cdump = $memcache->getExtendedStats('cachedump',(int)$slabId);
foreach($cdump AS $server => $entries) {
if($entries) {
foreach($entries AS $eName => $eData) {
$list[$eName] = array(
'key' => $eName,
'server' => $server,
'slabId' => $slabId,
'detail' => $eData,
'age' => $items[$server]['items'][$slabId]['age'],
);
}
}
}
}
}
ksort($list);
print_r($list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment