From b5f836e4af705679e13506c4edfe67ca3039f004 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 18 May 2011 08:10:27 -0400
Subject: [PATCH] - Make memcached cache not system-wide

---
 program/include/rcube_cache.php |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/program/include/rcube_cache.php b/program/include/rcube_cache.php
index d38c237..dda0988 100644
--- a/program/include/rcube_cache.php
+++ b/program/include/rcube_cache.php
@@ -208,7 +208,7 @@
         }
 
         if ($this->type == 'memcache') {
-            $data = $this->db->get($key);
+            $data = $this->db->get($this->mc_key($key));
 	        
             if ($data) {
                 $this->cache_sums[$key] = md5($data);
@@ -263,6 +263,7 @@
         }
 
         if ($this->type == 'memcache') {
+            $key = $this->mc_key($key);
             $result = $this->db->replace($key, $data, MEMCACHE_COMPRESSED);
             if (!$result)
                 $result = $this->db->set($key, $data, MEMCACHE_COMPRESSED);
@@ -313,7 +314,7 @@
         }
 
         if ($this->type == 'memcache') {
-            return $this->db->delete($key);
+            return $this->db->delete($this->mc_key($key));
         }
 
         $this->db->query(
@@ -325,4 +326,15 @@
         unset($this->cache_keys[$key]);
     }
 
+
+    /**
+     * Creates per-user Memcache key
+     *
+     * @param string $key Cache key
+     * @access private
+     */
+    private function mc_key($key)
+    {
+        return sprintf('[%d]%s', $this->userid, $key);
+    }
 }

--
Gitblit v1.9.1