Remove the static dependency on OC_Util from Memcache
This commit is contained in:
parent
cd147bb37a
commit
4d65a80892
4 changed files with 23 additions and 2 deletions
|
@ -18,7 +18,7 @@ abstract class Cache implements \ArrayAccess {
|
||||||
* @param string $prefix
|
* @param string $prefix
|
||||||
*/
|
*/
|
||||||
public function __construct($prefix = '') {
|
public function __construct($prefix = '') {
|
||||||
$this->prefix = \OC_Util::getInstanceId() . '/' . $prefix;
|
$this->prefix = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrefix() {
|
public function getPrefix() {
|
||||||
|
|
|
@ -9,6 +9,18 @@
|
||||||
namespace OC\Memcache;
|
namespace OC\Memcache;
|
||||||
|
|
||||||
class Factory {
|
class Factory {
|
||||||
|
/**
|
||||||
|
* @var string $globalPrefix
|
||||||
|
*/
|
||||||
|
private $globalPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $globalPrefix
|
||||||
|
*/
|
||||||
|
public function __construct($globalPrefix) {
|
||||||
|
$this->globalPrefix = $globalPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a cache instance, will return null if no backend is available
|
* get a cache instance, will return null if no backend is available
|
||||||
*
|
*
|
||||||
|
@ -16,6 +28,7 @@ class Factory {
|
||||||
* @return \OC\Memcache\Cache
|
* @return \OC\Memcache\Cache
|
||||||
*/
|
*/
|
||||||
function create($prefix = '') {
|
function create($prefix = '') {
|
||||||
|
$prefix = $this->globalPrefix . '/' . $prefix;
|
||||||
if (XCache::isAvailable()) {
|
if (XCache::isAvailable()) {
|
||||||
return new XCache($prefix);
|
return new XCache($prefix);
|
||||||
} elseif (APCu::isAvailable()) {
|
} elseif (APCu::isAvailable()) {
|
||||||
|
|
|
@ -137,7 +137,8 @@ class Server extends SimpleContainer implements IServerContainer {
|
||||||
return new UserCache();
|
return new UserCache();
|
||||||
});
|
});
|
||||||
$this->registerService('MemCache', function ($c) {
|
$this->registerService('MemCache', function ($c) {
|
||||||
$factory = new \OC\Memcache\Factory();
|
$instanceId = \OC_Util::getInstanceId();
|
||||||
|
$factory = new \OC\Memcache\Factory($instanceId);
|
||||||
return $factory->create();
|
return $factory->create();
|
||||||
});
|
});
|
||||||
$this->registerService('ActivityManager', function($c) {
|
$this->registerService('ActivityManager', function($c) {
|
||||||
|
|
|
@ -141,6 +141,13 @@ interface IServerContainer {
|
||||||
*/
|
*/
|
||||||
function getCache();
|
function getCache();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an ICache instance
|
||||||
|
*
|
||||||
|
* @return \OCP\ICache
|
||||||
|
*/
|
||||||
|
function getMemCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current session
|
* Returns the current session
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue