[Pkg-owncloud-commits] [owncloud] 225/457: add seperate config option for locking memcache backend

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:06:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 6b965d71d170759a6c4c5d755a37f891f0166912
Author: Robin Appelman <icewind at owncloud.com>
Date:   Tue May 26 14:41:37 2015 +0200

    add seperate config option for locking memcache backend
---
 config/config.sample.php         |  6 ++++++
 lib/private/memcache/factory.php | 23 ++++++++++++++++++++++-
 lib/private/server.php           |  5 +++--
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/config/config.sample.php b/config/config.sample.php
index a9fafe7..23a27fa 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -1040,6 +1040,12 @@ $CONFIG = array(
 'filelocking.enabled' => false,
 
 /**
+ * Memory caching backend for file locking
+ * Because most memcache backends can clean values without warning using redis is recommended
+ */
+'memcache.locking' => '\OC\Memcache\Redis',
+
+/**
  * This entry is just here to show a warning in case somebody copied the sample
  * configuration. DO NOT ADD THIS SWITCH TO YOUR CONFIGURATION!
  *
diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php
index bbfd775..6e9aaa1 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 551012d..ab1506f 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);
 				}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list