Index: memcache.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/memcache/memcache.module,v
retrieving revision 1.3
diff -u -r1.3 memcache.module
--- memcache.module	12 Jan 2007 22:19:52 -0000	1.3
+++ memcache.module	6 Apr 2007 09:43:41 -0000
@@ -36,3 +36,40 @@
     dmemcache_delete($node->nid, 'node');
   }
 }
+
+/**
+ * Implementation of hook_init(). Avoids custom error handling for better
+ * behavior when stepping though in a debugger.
+ */
+function memcache_init() {
+  if (strstr($_SERVER['PHP_SELF'], 'update.php') || strstr($_GET['q'], 'autocomplete')) {
+    // update.php relies on standard error handler
+  }
+  else {
+    register_shutdown_function('memcache_shutdown');
+  }
+}
+
+/**
+ * See memcache_init() which registers this function as a shutdown function. Displays developer information in the footer.
+ */
+function memcache_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 (function_exists('user_access') && user_access('access devel information') && isset($memcache_statistics)) {
+    $gets = $memcache_statistics['get'];
+    $hits = $memcache_statistics['hit'];
+    $sets = $memcache_statistics['set'];
+    $hitrate = $gets > 0 ? floor(100 * $hits / $gets) : 0;
+    $summary = t('Memcache: Hits %hits/%gets (%rate%), Sets %sets', array('%hits' => $hits, '%gets' => $gets, '%sets' => $sets, '%rate' => $hitrate));
+    print '<div>' . $summary . '</div>';
+  }
+}
