diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-07-22 03:21:20 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-07-22 03:21:20 +0200 |
commit | 6843beeae97835573cf792c8367b41ecfeef5342 (patch) | |
tree | c9079ed6f5b4e1562e5377c65d27152ca42735fb /lib/cache.php | |
parent | 51566e87c7343385ae3b6854386c20974c94a53d (diff) | |
download | nextcloud-server-6843beeae97835573cf792c8367b41ecfeef5342.tar.gz nextcloud-server-6843beeae97835573cf792c8367b41ecfeef5342.zip |
add option to only get fast cache
Diffstat (limited to 'lib/cache.php')
-rw-r--r-- | lib/cache.php | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/lib/cache.php b/lib/cache.php index 36f409ab71a..55f189a5da8 100644 --- a/lib/cache.php +++ b/lib/cache.php @@ -15,24 +15,40 @@ class OC_Cache { * @var OC_Cache $global_cache */ static protected $global_cache; + /** + * @var OC_Cache $global_cache_fast + */ + static protected $global_cache_fast; + /** + * @var OC_Cache $user_cache_fast + */ + static protected $user_cache_fast; static protected $isFast=null; /** * get the global cache * @return OC_Cache */ - static public function getGlobalCache() { + static public function getGlobalCache($fast=false) { if (!self::$global_cache) { - $fast_cache = null; - if (!$fast_cache && function_exists('xcache_set')) { - $fast_cache = new OC_Cache_XCache(true); + self::$global_cache_fast = null; + if (!self::$global_cache_fast && function_exists('xcache_set')) { + self::$global_cache_fast = new OC_Cache_XCache(true); } - if (!$fast_cache && function_exists('apc_store')) { - $fast_cache = new OC_Cache_APC(true); + if (!self::$global_cache_fast && function_exists('apc_store')) { + self::$global_cache_fast = 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); + if (self::$global_cache_fast) { + self::$global_cache = new OC_Cache_Broker(self::$global_cache_fast, self::$global_cache); + } + } + if($fast){ + if(self::$global_cache_fast){ + return self::$global_cache_fast; + }else{ + return false; } } return self::$global_cache; @@ -42,18 +58,27 @@ class OC_Cache { * get the user cache * @return OC_Cache */ - static public function getUserCache() { + static public function getUserCache($fast=false) { if (!self::$user_cache) { - $fast_cache = null; - if (!$fast_cache && function_exists('xcache_set')) { - $fast_cache = new OC_Cache_XCache(); + self::$user_cache_fast = null; + if (!self::$user_cache_fast && function_exists('xcache_set')) { + self::$user_cache_fast = new OC_Cache_XCache(); } - if (!$fast_cache && function_exists('apc_store')) { - $fast_cache = new OC_Cache_APC(); + if (!self::$user_cache_fast && function_exists('apc_store')) { + self::$user_cache_fast = new OC_Cache_APC(); } + self::$user_cache = new OC_Cache_File(); - if ($fast_cache) { - self::$user_cache = new OC_Cache_Broker($fast_cache, self::$user_cache); + if (self::$user_cache_fast) { + self::$user_cache = new OC_Cache_Broker(self::$user_cache_fast, self::$user_cache); + } + } + + if($fast){ + if(self::$user_cache_fast){ + return self::$user_cache_fast; + }else{ + return false; } } return self::$user_cache; |