You are here

function memcache_shutdown in Memcache API and Integration 5.2

See memcache_init() which registers this function as a shutdown function. Displays memcache stats in the footer.

1 string reference to 'memcache_shutdown'
memcache_init in ./memcache.module

File

./memcache.module, line 20

Code

function memcache_shutdown() {
  global $user, $_memcache_statistics;
  $output = '';

  // Try not to break non html pages.
  if (function_exists('drupal_get_headers')) {
    $headers = drupal_get_headers();
    if (strstr($headers, 'xml') || strstr($headers, 'javascript') || strstr($headers, 'plain')) {
      return;
    }
  }
  if (user_access('access memcache statistics')) {
    drupal_add_js(drupal_get_path('module', 'memcache') . '/memcache.js');
    $stats = array();
    foreach ($_memcache_statistics as $stat => $val) {
      $stats[] = "<strong>{$stat}:</strong> " . theme('item_list', $val);
    }
    if (!empty($stats)) {
      $output = theme('item_list', $stats);

      // this makes sure all of the HTML is within the <body> even though this <script> is outside it
      print '<div id="memcache-devel"><h2>' . t('Memcache statistics') . '</h2>' . $output . '</div>';
    }
  }
}