Skip to content

Instantly share code, notes, and snippets.

@CrookedNumber
Created November 12, 2012 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrookedNumber/4057350 to your computer and use it in GitHub Desktop.
Save CrookedNumber/4057350 to your computer and use it in GitHub Desktop.
Drupal-focused memcache GUI
<?php
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211)
or die ("Could not connect to memcache server");
$cells = '';
$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 $keys => $arrVal) {
if (!is_array($arrVal)) continue;
foreach ($arrVal as $k => $v) {
$pieces = explode('-', $k);
$obj = $memcache->get($k);
$cid = $obj->cid;
$data = $obj->data;
$headers = $obj->headers;
$flushes = $obj->flushes;
$expire = $obj->expire;
$cells .= '<tr><td>' . urldecode(array_shift($pieces)) . '</td><td>' . $cid . '</td><td>' . print_r($data, 1) . '</td><td>' . $headers . '</td><td>' . $flushes . '</td><td>' . $expire . '</td></tr>';
}
}
}
}
print "<table border='1'><tr><th>bin</th><th>cid</th><th>data</th><th>headers</th><th>flushes</th><th>expire</th></tr>$cells</table>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment