? memcache-942914.patch
Index: memcache.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/memcache/memcache.inc,v
retrieving revision 1.15.2.8.2.28
diff -u -p -r1.15.2.8.2.28 memcache.inc
--- memcache.inc	28 Dec 2010 11:11:27 -0000	1.15.2.8.2.28
+++ memcache.inc	10 Jan 2011 21:51:31 -0000
@@ -13,7 +13,7 @@ define('MEMCACHE_WILDCARD_INVALIDATE', 8
 
 /**
  * Return data from the persistent cache.
- * 
+ *
  * Data may be stored as either plain text or as serialized data.
  * cache_get() will automatically return unserialized objects and arrays.
  *
@@ -24,6 +24,12 @@ define('MEMCACHE_WILDCARD_INVALIDATE', 8
  *   'cache_menu', 'cache_page', or 'cache' for the default cache.
  */
 function cache_get($cid, $table = 'cache') {
+  // Allow cache_page table to have a modified cache ID
+  $modifier = variable_get("memcache_cache_page_cid_modifier", FALSE);
+  if ($modifier && $table == 'cache_page' && function_exists($modifier)) {
+    $cid = $modifier($cid, 'get');
+  }
+
   // Handle excluded bins first.
   $bins = variable_get('memcache_bins', array());
   if (!is_null($table) && isset($bins[$table]) && $bins[$table] == 'database') {
@@ -85,7 +91,7 @@ function cache_get($cid, $table = 'cache
  *   The cache ID of the data to store.
  * @param $data
  *   The data to store in the cache. Complex data types will be automatically
- *   serialized before insertion. Strings will be stored as plain text and 
+ *   serialized before insertion. Strings will be stored as plain text and
  *   not serialized.
  * @param $table
  *   The table $table to store the data in. Valid core values are 'cache_filter',
@@ -102,12 +108,18 @@ function cache_get($cid, $table = 'cache
  *   A string containing HTTP header information for cached pages.
  */
 function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) {
+  // Allow cache_page table to have a modified cache ID
+  $modifier = variable_get("memcache_cache_page_cid_modifier", FALSE);
+  if ($modifier && $table == 'cache_page' && function_exists($modifier)) {
+    $cid = $modifier($cid, 'set');
+  }
+
   // Handle database fallback first.
   $bins = variable_get('memcache_bins', array());
   if (!is_null($table) && isset($bins[$table]) && $bins[$table] == 'database') {
     return _cache_set($cid, $data, $table, $expire, $headers);
   }
-  
+
   $created = $_SERVER['REQUEST_TIME'];
 
   // Create new cache object.
@@ -146,7 +158,7 @@ function cache_set($cid, $data, $table =
  * entries will be cleared from the cache_page and cache_block tables.
  *
  * Memcache logic is simpler than the core cache because memcache doesn't have
- * a minimum cache lifetime consideration (it handles it internally), and 
+ * a minimum cache lifetime consideration (it handles it internally), and
  * doesn't support wildcards.  Wildcard flushes result in the entire table
  * being flushed.
  *
@@ -164,12 +176,18 @@ function cache_set($cid, $data, $table =
  *   match. If '*' is given as $cid, the table $table will be emptied.
  */
 function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) {
+  // Allow cache_page table to have a modified cache ID
+  $modifier = variable_get("memcache_cache_page_cid_modifier", FALSE);
+  if ($modifier && $table == 'cache_page' && function_exists($modifier)) {
+    $cid = $modifier($cid, 'clear');
+  }
+
   // Handle database fallback first.
   $bins = variable_get('memcache_bins', array());
   if (!is_null($table) && isset($bins[$table]) && $bins[$table] == 'database') {
     return _cache_clear_all($cid, $table, $wildcard);
   }
-  
+
   // Default behavior for when cache_clear_all() is called without parameters
   // is to clear all of the expirable entries in the block and page caches.
   if (!isset($cid) && !isset($table)) {
