mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Cache: Add APC and XCache to global cache handler
This commit is contained in:
parent
4e4a1a4274
commit
531c1c509c
3 changed files with 30 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
11
lib/cache/apc.php
vendored
11
lib/cache/apc.php
vendored
|
|
@ -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) {
|
||||
|
|
|
|||
11
lib/cache/xcache.php
vendored
11
lib/cache/xcache.php
vendored
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue