Commit 0d0fc19e authored by robertDouglass's avatar robertDouglass
Browse files

Improving devel stats and handling the cache_set case where the expiration...

Improving devel stats and handling the cache_set case where the expiration time is a timestamp in the future.
parent b84e6070
......@@ -2,7 +2,7 @@
// $ID$
global $memcache_statistics;
$memcache_statistics = array('get' => 0, 'set' => 0, 'hit' => 0);
$memcache_statistics = array('get' => array(), 'set' => array(), 'hit' => array());
/*
* A memcache API for Drupal.
......@@ -24,7 +24,7 @@ $memcache_statistics = array('get' => 0, 'set' => 0, 'hit' => 0);
*/
function dmemcache_set($key, $value, $exp = 0, $bin = 'cache') {
global $memcache_statistics;
$memcache_statistics['set']++;
$memcache_statistics['set'][] = $key;
if ($mc = dmemcache_object($bin)) {
$full_key = dmemcache_key($key, $bin);
if (!$mc->set($full_key, $value, TRUE, $exp)) {
......@@ -47,12 +47,12 @@ function dmemcache_set($key, $value, $exp = 0, $bin = 'cache') {
*/
function dmemcache_get($key, $bin = 'cache') {
global $memcache_statistics;
$memcache_statistics['get']++;
$memcache_statistics['get'][] = $key;
if ($mc = dmemcache_object($bin)) {
$full_key = dmemcache_key($key, $bin);
$result = $mc->get($full_key);
if ($result) {
$memcache_statistics['hit']++;
$memcache_statistics['hit'][] = $key;
}
return $result;
}
......@@ -304,6 +304,9 @@ function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $he
if ($expire === CACHE_PERMANENT && $headers === NULL) {
dmemcache_set($cid, $data, 0, $table);
}
elseif ($expire > time() && $headers === NULL) {
dmemcache_set($cid, $data, $expire, $table);
}
}
/**
......
......@@ -31,7 +31,7 @@ function memcache_shutdown() {
if ($user->uid == 1) {
$stats = array();
foreach ($memcache_statistics as $stat => $val) {
$stats[] = "<strong>$stat:</strong> $val";
$stats[] = "<strong>$stat:</strong> ". theme('item_list', $val);
}
if (!empty($stats)) {
$output = theme('item_list', $stats);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment