]> source.dussan.org Git - nextcloud-server.git/commitdiff
Cache: Add APC and XCache to global cache handler
authorBart Visscher <bartv@thisnet.nl>
Mon, 25 Jun 2012 15:42:50 +0000 (17:42 +0200)
committerBart Visscher <bartv@thisnet.nl>
Mon, 25 Jun 2012 19:05:10 +0000 (21:05 +0200)
lib/cache.php
lib/cache/apc.php
lib/cache/xcache.php

index e6f2beeb30620994cbbff880cce662c7a7c6141b..1f269174fad663cf6bb2b6ad3611379d7afee971 100644 (file)
@@ -12,7 +12,17 @@ class OC_Cache {
 
        static public function getGlobalCache() {
                if (!self::$global_cache) {
+                       $fast_cache = null;
+                       if (!$fast_cache && function_exists('xcache_set')) {
+                               $fast_cache = new OC_Cache_XCache(true);
+                       }
+                       if (!$fast_cache && function_exists('apc_store')) {
+                               $fast_cache = new OC_Cache_APC(true);
+                       }
                        self::$global_cache = new OC_Cache_FileGlobal();
+                       if ($fast_cache) {
+                               self::$global_cache = new OC_Cache_Broker($fast_cache, self::$global_cache);
+                       }
                }
                return self::$global_cache;
        }
index b1ce87f52671aa388e5db52b4911438b05143740..6cf47d0c1586cfedaeb7937bcacc14f3e4f870e1 100644 (file)
@@ -7,11 +7,20 @@
  */
 
 class OC_Cache_APC {
+       protected $prefix;
+
+       public function __construct($global = false) {
+               $this->prefix = OC_Util::getInstanceId().'/';
+               if (!$global) {
+                       $this->prefix .= OC_User::getUser().'/';
+               }
+       }
+
        /**
         * entries in APC gets namespaced to prevent collisions between owncloud instances and users
         */
        protected function getNameSpace() {
-               return OC_Util::getInstanceId().'/'.OC_User::getUser().'/';
+               return $this->prefix;
        }
 
        public function get($key) {
index b57338929e05d58442aca21abcc6009a13f67e9b..bd55cee8f6bbcb186d6a8781ffe528e36ebf6512 100644 (file)
@@ -7,11 +7,20 @@
  */
 
 class OC_Cache_XCache {
+       protected $prefix;
+
+       public function __construct($global = false) {
+               $this->prefix = OC_Util::getInstanceId().'/';
+               if (!$global) {
+                       $this->prefix .= OC_User::getUser().'/';
+               }
+       }
+
        /**
         * entries in XCache gets namespaced to prevent collisions between owncloud instances and users
         */
        protected function getNameSpace() {
-               return OC_Util::getInstanceId().'/'.OC_User::getUser().'/';
+               return $this->prefix;
        }
 
        public function get($key) {