Index: dmemcache.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/memcache/dmemcache.inc,v retrieving revision 1.1.2.7.2.14 diff -u -p -r1.1.2.7.2.14 dmemcache.inc --- dmemcache.inc 26 Aug 2010 22:17:48 -0000 1.1.2.7.2.14 +++ dmemcache.inc 14 Sep 2010 15:30:41 -0000 @@ -10,7 +10,7 @@ */ global $_memcache_statistics; -$_memcache_statistics = array('get' => array(), 'set' => array(), 'hit' => array()); +$_memcache_statistics = array(); /* * A memcache API for Drupal. @@ -32,10 +32,9 @@ $_memcache_statistics = array('get' => a */ function dmemcache_set($key, $value, $exp = 0, $bin = 'cache') { global $_memcache_statistics; - $_memcache_statistics['set'][] = $key; - $_memcache_statistics['bins'][] = $bin; + $full_key = dmemcache_key($key, $bin); + $_memcache_statistics[] = array('set', $bin, $full_key, ''); if ($mc = dmemcache_object($bin)) { - $full_key = dmemcache_key($key, $bin); if (class_exists('Memcached')) { return $mc->set($full_key, $value, $exp); } @@ -73,10 +72,9 @@ function dmemcache_set($key, $value, $ex */ function dmemcache_add($key, $value, $exp = 0, $bin = 'cache', $mc = NULL, $flag = FALSE) { global $_memcache_statistics; - $_memcache_statistics['add'][] = $key; - $_memcache_statistics['bins'][] = $bin; + $full_key = dmemcache_key($key, $bin); + $_memcache_statistics[] = array('add', $bin, $full_key, ''); if ($mc || ($mc = dmemcache_object($bin))) { - $full_key = dmemcache_key($key, $bin); if (class_exists('Memcached')) { return $mc->add($full_key, $value, $exp); } @@ -97,10 +95,10 @@ function dmemcache_add($key, $value, $ex */ function dmemcache_get($key, $bin = 'cache') { global $_memcache_statistics; - $_memcache_statistics['get'][] = $key; - $_memcache_statistics['bins'][] = $bin; + $full_key = dmemcache_key($key, $bin); + $statistics = array('get', $bin, $full_key); + $success = '0'; if ($mc = dmemcache_object($bin)) { - $full_key = dmemcache_key($key, $bin); $result = $mc->get($full_key); if ($result) { // We check $result->expire to see if the object has expired. If so, we @@ -116,9 +114,12 @@ function dmemcache_get($key, $bin = 'cac $result = FALSE; } else { - $_memcache_statistics['hit'][] = $key; + $success = '1'; } } + $statistics[] = $success; + $_memcache_statistics[] = $statistics; + return $result; } } @@ -130,19 +131,18 @@ function dmemcache_get($key, $bin = 'cac * @param $bin The bin in which the item was stored. * * @return The item which was originally saved or FALSE - * - * TODO: Record statistics w/ multi-get */ function dmemcache_get_multi($keys, $bin = 'cache', $mc = NULL) { global $_memcache_statistics; - $_memcache_statistics['get'] = array_merge($_memcache_statistics['get'], $keys); - $_memcache_statistics['bins'][] = $bin; + $full_keys = array(); + $statistics = array(); + foreach ($keys as $key => $cid) { + $full_key = dmemcache_key($cid, $bin); + $statistics[$full_key] = array('getMulti', $bin, $full_key); + $full_keys[] = $full_key; + } $results = array(); if ($mc || ($mc = dmemcache_object($bin))) { - $full_keys = array(); - foreach ($keys as $key => $cid) { - $full_keys[] = dmemcache_key($cid, $bin); - } if (class_exists('Memcached')) { $results = $mc->getMulti($full_keys); } @@ -150,6 +150,10 @@ function dmemcache_get_multi($keys, $bin $results = $mc->get($full_keys); } } + foreach ($statistics as $key => $values) { + $values[] = isset($results[$key]) ? '1': '0'; + $_memcache_statistics[] = $values; + } return $results; } @@ -162,8 +166,10 @@ function dmemcache_get_multi($keys, $bin * @return Returns TRUE on success or FALSE on failure. */ function dmemcache_delete($key, $bin = 'cache') { + global $_memcache_statistics; + $full_key = dmemcache_key($key, $bin); + $_memcache_statistics[] = array('delete', $bin, $full_key, ''); if ($mc = dmemcache_object($bin)) { - $full_key = dmemcache_key($key, $bin); return $mc->delete($full_key); } return FALSE; @@ -180,6 +186,8 @@ function dmemcache_delete($key, $bin = ' * @return Returns TRUE on success or FALSE on failure. */ function dmemcache_flush($bin = 'cache') { + global $_memcache_statistics; + $_memcache_statistics[] = array('flush', $bin, '', ''); if ($mc = dmemcache_object($bin)) { return $mc->flush(); } Index: memcache_admin/memcache_admin.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/memcache/memcache_admin/memcache_admin.module,v retrieving revision 1.3.2.10.2.2 diff -u -p -r1.3.2.10.2.2 memcache_admin.module --- memcache_admin/memcache_admin.module 21 Nov 2008 15:18:32 -0000 1.3.2.10.2.2 +++ memcache_admin/memcache_admin.module 14 Sep 2010 15:30:42 -0000 @@ -232,13 +232,9 @@ function memcache_admin_shutdown() { } if (variable_get('show_memcache_statistics', TRUE) && function_exists('user_access') && user_access('access memcache statistics')) { - $stats = array(); - - foreach ($_memcache_statistics as $stat => $value) { - $stats[] = "$stat: ". theme('item_list', $value); - } - if (!empty($stats)) { - $output = theme('item_list', $stats); + if (!empty($_memcache_statistics)) { + $headers = array(t('Operation'), t('Bin'), t('Key'), t('Hit')); + $output = theme('table', $headers, $_memcache_statistics); // this makes sure all of the HTML is within the even though this