Cache: Use getUserCache cache in OC_Cache

remotes/origin/stable45
Bart Visscher 14 years ago
parent cae089df91
commit 4e4a1a4274
  1. 61
      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();
}
}

Loading…
Cancel
Save