? apc_tests_fix.patch
? provide_default_static.patch
Index: cacherouter.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cacherouter/cacherouter.inc,v
retrieving revision 1.2.2.4
diff -u -p -r1.2.2.4 cacherouter.inc
--- cacherouter.inc	31 Oct 2008 00:55:16 -0000	1.2.2.4
+++ cacherouter.inc	6 Nov 2008 14:15:57 -0000
@@ -153,6 +153,9 @@ function cache_clear_all($cid = NULL, $t
       }
     }
     else {
+      if ($cid == '*') {
+        return;
+      }
       $cache->delete($cid, $table);
     }
   }
Index: engines/apc.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cacherouter/engines/apc.php,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 apc.php
--- engines/apc.php	5 Nov 2008 00:33:56 -0000	1.1.2.10
+++ engines/apc.php	6 Nov 2008 14:15:57 -0000
@@ -1,6 +1,13 @@
 <?php
 
 class apcCache extends Cache {
+  var $temporary_lookup_key;
+
+  function __construct($bin) {
+    parent::__construct($bin);
+    $this->temporary_lookup_key = (!empty($this->prefix) ? $this->prefix .'-' : '') .'lookup_temporary_'. $bin;
+  }
+
   /**
    * page_fast_cache
    *   This tells CacheRouter to use page_fast_cache.
@@ -12,6 +19,24 @@ class apcCache extends Cache {
   }
   
   /**
+   * get_temporary_lookup
+   *   This returns the current temporary lookup.
+   * 
+   *   @return array 
+   */
+  function get_temporary_lookup() {
+    // Get lookup table to be able to keep track of bins
+    $temporary_lookup = apc_fetch($this->temporary_lookup_key);
+
+    // If the temporary table is empty, initialize table
+    if (empty($temporary_lookup)) {
+      $temporary_lookup = array();
+    }
+    
+    return $temporary_lookup;
+  }
+  
+  /**
    * get()
    *   Return item from cache if it is available.
    *
@@ -50,15 +75,12 @@ class apcCache extends Cache {
    *   Returns TRUE on success or FALSE on failure
    */
   function set($key, $value, $expire = CACHE_PERMANENT, $headers = NULL) {
-    if ($expire == CACHE_TEMPORARY) {
-      $expire = 180;
-    }
     // Create new cache object.
     $cache = new stdClass;
     $cache->cid = $key;
     $cache->created = time();
-    $cache->expire = $expire;
     $cache->headers = $headers;
+    $cache->expire = $expire;
 
     if (!is_string($value)) {
       $cache->serialized = TRUE;
@@ -80,9 +102,35 @@ class apcCache extends Cache {
 
       // Set key to 1 so we can keep track of the bin
       $lookup[$this->key($key)] = 1;
+      
+      // Prepare the key
+      $key = $this->key($key);
+
+      // What kind of expiration is being used.
+      switch($expire) {
+        case CACHE_PERMANENT:
+          $set_result = apc_store($key, $cache);
+          break;
+        case CACHE_TEMPORARY:
+          if (variable_get('cache_lifetime', 0) > 0) {
+            $set_result = apc_store($key, $cache, variable_get('cache_lifetime', 0));
+          }
+          else {
+            $set_result = apc_store($key, $cache);
+            if ($set_result) {
+              $temporary_lookup = $this->get_temporary_lookup();
+              $temporary_lookup[$key] = TRUE;
+              apc_store($this->temporary_lookup_key, $temporary_lookup);
+            }
+          }
+          break;
+        default:
+          $set_result = apc_store($key, $cache, $expire - time());
+          break;
+      }
 
       // Attempt to store full key and value
-      if (!apc_store($this->key($key), $cache, $expire)) {
+      if (!$set_result) {
         unset($lookup[$this->key($key)]);
         $return = FALSE;
       }
@@ -152,6 +200,9 @@ class apcCache extends Cache {
   function flush() {
     parent::flush();
     if ($this->lock()) {
+      // Get temporary lookup
+      $temporary_lookup = $this->get_temporary_lookup();
+      
       // Get lookup table to be able to keep track of bins
       $lookup = apc_fetch($this->lookup);
     
@@ -162,7 +213,7 @@ class apcCache extends Cache {
       }
 
       // Cycle through keys and remove each entry from the cache
-      foreach ($lookup as $k => $v) {
+      foreach ($temporary_lookup as $k => $v) {
         if (apc_delete($k)) {
           unset($lookup[$k]);
         }
@@ -170,7 +221,8 @@ class apcCache extends Cache {
 
       // Resave the lookup table (even on failure)
       apc_store($this->lookup, $lookup);
-
+      apc_store($this->temporary_lookup_key, array());
+      
       // Remove lock
       $this->unlock();
     }
