Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-06-25 10:53:17 +0400
committerBart Visscher <bartv@thisnet.nl>2012-06-25 23:05:10 +0400
commit4e4a1a4274940a9aa7b4c9313d13f8aeb80123ba (patch)
treec16e8924b8e2c7b97c281db911c2d580ec3874a3 /lib/cache.php
parentcae089df91bf2ba9413145dc800d9fa77aab08cb (diff)
Cache: Use getUserCache cache in OC_Cache
Diffstat (limited to 'lib/cache.php')
-rw-r--r--lib/cache.php61
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();
}
}