Commit 9621c2db authored by lyricnz's avatar lyricnz
Browse files

Update statistics variable name. See Coding Standards http://drupal.org/node/318

"If you need to define global variables, their name should start with a single underscore followed by the module/theme name and another underscore"
parent c9fe2012
<?php <?php
// $ID$ // $ID$
global $memcache_statistics; global $_memcache_statistics;
$memcache_statistics = array('get' => array(), 'set' => array(), 'hit' => array()); $_memcache_statistics = array('get' => array(), 'set' => array(), 'hit' => array());
/* /*
* A memcache API for Drupal. * A memcache API for Drupal.
...@@ -23,8 +23,8 @@ $memcache_statistics = array('get' => array(), 'set' => array(), 'hit' => array( ...@@ -23,8 +23,8 @@ $memcache_statistics = array('get' => array(), 'set' => array(), 'hit' => array(
* @return bool * @return bool
*/ */
function dmemcache_set($key, $value, $exp = 0, $bin = 'cache') { function dmemcache_set($key, $value, $exp = 0, $bin = 'cache') {
global $memcache_statistics; global $_memcache_statistics;
$memcache_statistics['set'][] = $key; $_memcache_statistics['set'][] = $key;
if ($mc = dmemcache_object($bin)) { if ($mc = dmemcache_object($bin)) {
$full_key = dmemcache_key($key, $bin); $full_key = dmemcache_key($key, $bin);
if (!$mc->set($full_key, $value, TRUE, $exp)) { if (!$mc->set($full_key, $value, TRUE, $exp)) {
...@@ -46,13 +46,13 @@ function dmemcache_set($key, $value, $exp = 0, $bin = 'cache') { ...@@ -46,13 +46,13 @@ function dmemcache_set($key, $value, $exp = 0, $bin = 'cache') {
* @return The item which was originally saved or FALSE * @return The item which was originally saved or FALSE
*/ */
function dmemcache_get($key, $bin = 'cache') { function dmemcache_get($key, $bin = 'cache') {
global $memcache_statistics; global $_memcache_statistics;
$memcache_statistics['get'][] = $key; $_memcache_statistics['get'][] = $key;
if ($mc = dmemcache_object($bin)) { if ($mc = dmemcache_object($bin)) {
$full_key = dmemcache_key($key, $bin); $full_key = dmemcache_key($key, $bin);
$result = $mc->get($full_key); $result = $mc->get($full_key);
if ($result) { if ($result) {
$memcache_statistics['hit'][] = $key; $_memcache_statistics['hit'][] = $key;
} }
return $result; return $result;
} }
......
...@@ -16,7 +16,7 @@ function memcache_init() { ...@@ -16,7 +16,7 @@ function memcache_init() {
* Displays memcache stats in the footer. * Displays memcache stats in the footer.
*/ */
function memcache_shutdown() { function memcache_shutdown() {
global $user, $memcache_statistics; global $user, $_memcache_statistics;
$output = ''; $output = '';
...@@ -30,7 +30,7 @@ function memcache_shutdown() { ...@@ -30,7 +30,7 @@ function memcache_shutdown() {
if ($user->uid == 1) { if ($user->uid == 1) {
$stats = array(); $stats = array();
foreach ($memcache_statistics as $stat => $val) { foreach ($_memcache_statistics as $stat => $val) {
$stats[] = "<strong>$stat:</strong> ". theme('item_list', $val); $stats[] = "<strong>$stat:</strong> ". theme('item_list', $val);
} }
if (!empty($stats)) { if (!empty($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