diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-06-25 08:53:17 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-06-25 21:05:10 +0200 |
commit | 4e4a1a4274940a9aa7b4c9313d13f8aeb80123ba (patch) | |
tree | c16e8924b8e2c7b97c281db911c2d580ec3874a3 /lib | |
parent | cae089df91bf2ba9413145dc800d9fa77aab08cb (diff) | |
download | nextcloud-server-4e4a1a4274940a9aa7b4c9313d13f8aeb80123ba.tar.gz nextcloud-server-4e4a1a4274940a9aa7b4c9313d13f8aeb80123ba.zip |
Cache: Use getUserCache cache in OC_Cache
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cache.php | 61 |
1 files changed, 24 insertions, 37 deletions
diff --git a/lib/cache.php b/lib/cache.php index 66d1049fb52..e6f2beeb306 100644 --- a/lib/cache.php +++ b/lib/cache.php @@ -7,7 +7,7 @@ */ class OC_Cache { - static protected $cache; + static protected $user_cache; static protected $global_cache; static public function getGlobalCache() { @@ -18,61 +18,48 @@ class OC_Cache { } static public function getUserCache() { - if (!self::$cache) { - self::init(); - } - return self::$cache; - } - static protected function init() { - $fast_cache = null; - if (!$fast_cache && function_exists('xcache_set')) { - $fast_cache = new OC_Cache_XCache(); - } - if (!$fast_cache && function_exists('apc_store')) { - $fast_cache = new OC_Cache_APC(); - } - self::$cache = new OC_Cache_File(); - if ($fast_cache) { - self::$cache = new OC_Cache_Broker($fast_cache, self::$cache); + if (!self::$user_cache) { + $fast_cache = null; + if (!$fast_cache && function_exists('xcache_set')) { + $fast_cache = new OC_Cache_XCache(); + } + if (!$fast_cache && function_exists('apc_store')) { + $fast_cache = 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); + } } + return self::$user_cache; } static public function get($key) { - if (!self::$cache) { - self::init(); - } - return self::$cache->get($key); + $user_cache = self::getUserCache(); + return $user_cache->get($key); } static public function set($key, $value, $ttl=0) { if (empty($key)) { return false; } - if (!self::$cache) { - self::init(); - } - return self::$cache->set($key, $value, $ttl); + $user_cache = self::getUserCache(); + return $user_cache->set($key, $value, $ttl); } static public function hasKey($key) { - if (!self::$cache) { - self::init(); - } - return self::$cache->hasKey($key); + $user_cache = self::getUserCache(); + return $user_cache->hasKey($key); } static public function remove($key) { - if (!self::$cache) { - self::init(); - } - return self::$cache->remove($key); + $user_cache = self::getUserCache(); + return $user_cache->remove($key); } static public function clear() { - if (!self::$cache) { - self::init(); - } - return self::$cache->clear(); + $user_cache = self::getUserCache(); + return $user_cache->clear(); } } |