]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/cache.php
Wordpress 2.0.11
[autoinstalls/wordpress.git] / wp-includes / cache.php
index 79a0566bcc8fd6dfa5471704ea986793c3dc312e..334a9610187ff6f0946f0f0eee21e960382a724e 100644 (file)
@@ -8,6 +8,8 @@ function wp_cache_add($key, $data, $flag = '', $expire = 0) {
 function wp_cache_close() {
        global $wp_object_cache;
 
+       if ( ! isset($wp_object_cache) )
+               return;
        return $wp_object_cache->save();
 }
 
@@ -30,9 +32,7 @@ function wp_cache_get($id, $flag = '') {
 }
 
 function wp_cache_init() {
-       global $wp_object_cache;
-
-       $wp_object_cache = new WP_Object_Cache();
+       $GLOBALS['wp_object_cache'] =& new WP_Object_Cache();
 }
 
 function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
@@ -404,8 +404,14 @@ class WP_Object_Cache {
        }
 
        function WP_Object_Cache() {
+               return $this->__construct();
+       }
+       
+       function __construct() {
                global $blog_id;
 
+               register_shutdown_function(array(&$this, "__destruct"));
+
                if (defined('DISABLE_CACHE'))
                        return;
 
@@ -440,5 +446,10 @@ class WP_Object_Cache {
 
                $this->blog_id = $this->hash($blog_id);
        }
+
+       function __destruct() {
+               $this->save();
+               return true;    
+       }
 }
 ?>