diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-05-26 14:41:37 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-06-01 13:22:56 +0200 |
commit | 6b965d71d170759a6c4c5d755a37f891f0166912 (patch) | |
tree | 92e1c008a1b31b28fb31aa6fa6e0a9a1270562a3 /lib/private | |
parent | 72847dbc7794f250fb59ddf5e679d226909ec065 (diff) | |
download | nextcloud-server-6b965d71d170759a6c4c5d755a37f891f0166912.tar.gz nextcloud-server-6b965d71d170759a6c4c5d755a37f891f0166912.zip |
add seperate config option for locking memcache backend
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/memcache/factory.php | 23 | ||||
-rw-r--r-- | lib/private/server.php | 5 |
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php index bbfd775c774..6e9aaa11d85 100644 --- a/lib/private/memcache/factory.php +++ b/lib/private/memcache/factory.php @@ -47,12 +47,18 @@ class Factory implements ICacheFactory { private $distributedCacheClass; /** + * @var string $lockingCacheClass + */ + private $lockingCacheClass; + + /** * @param string $globalPrefix * @param string|null $localCacheClass * @param string|null $distributedCacheClass + * @param string|null $lockingCacheClass */ public function __construct($globalPrefix, - $localCacheClass = null, $distributedCacheClass = null) + $localCacheClass = null, $distributedCacheClass = null, $lockingCacheClass = null) { $this->globalPrefix = $globalPrefix; @@ -62,8 +68,23 @@ class Factory implements ICacheFactory { if (!($distributedCacheClass && $distributedCacheClass::isAvailable())) { $distributedCacheClass = $localCacheClass; } + if (!($lockingCacheClass && $lockingCacheClass::isAvailable())) { + // dont fallback since the fallback might not be suitable for storing lock + $lockingCacheClass = '\OC\Memcache\Null'; + } $this->localCacheClass = $localCacheClass; $this->distributedCacheClass = $distributedCacheClass; + $this->lockingCacheClass = $lockingCacheClass; + } + + /** + * create a cache instance for storing locks + * + * @param string $prefix + * @return \OCP\IMemcache + */ + public function createLocking($prefix = '') { + return new $this->lockingCacheClass($this->globalPrefix . '/' . $prefix); } /** diff --git a/lib/private/server.php b/lib/private/server.php index 551012d8355..ab1506fa13a 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -234,7 +234,8 @@ class Server extends SimpleContainer implements IServerContainer { $prefix = md5($instanceId.'-'.$version.'-'.$path); return new \OC\Memcache\Factory($prefix, $config->getSystemValue('memcache.local', null), - $config->getSystemValue('memcache.distributed', null) + $config->getSystemValue('memcache.distributed', null), + $config->getSystemValue('memcache.locking', null) ); } @@ -426,7 +427,7 @@ class Server extends SimpleContainer implements IServerContainer { if ($c->getConfig()->getSystemValue('filelocking.enabled', false) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { /** @var \OC\Memcache\Factory $memcacheFactory */ $memcacheFactory = $c->getMemCacheFactory(); - $memcache = $memcacheFactory->createDistributed('lock'); + $memcache = $memcacheFactory->createLocking('lock'); if (!($memcache instanceof \OC\Memcache\Null)) { return new MemcacheLockingProvider($memcache); } |