You are here

function memcache_admin_shutdown in Memcache API and Integration 5

Same name and namespace in other branches
  1. 6 memcache_admin/memcache_admin.module \memcache_admin_shutdown()
  2. 7 memcache_admin/memcache_admin.module \memcache_admin_shutdown()

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

1 string reference to 'memcache_admin_shutdown'
memcache_admin_init in memcache_admin/memcache_admin.module
For the collection of memcache stats. This small .js file makes sure that the HTML displaying the stats is inside of the <body> part of the HTML document.

File

memcache_admin/memcache_admin.module, line 226

Code

function memcache_admin_shutdown() {
  global $_memcache_statistics;

  // 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 (variable_get('show_memcache_statistics', TRUE) && function_exists('user_access') && user_access('access memcache statistics')) {
    $data = array();
    foreach ($_memcache_statistics as $bin => $stats) {
      foreach ($stats as $key => $value) {
        $stats[$key] = check_plain($value);
      }
      $data[] = "<strong>{$stat}:</strong> " . theme('item_list', $stats);
    }
    if (!empty($data)) {
      $output = theme('item_list', $data);

      // 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>';
    }
  }
}