CrookedNumber
11/12/2012 - 3:33 AM

Drupal-focused memcache GUI

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>";