aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/memcache/factory.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/memcache/factory.php')
-rw-r--r--lib/private/memcache/factory.php23
1 files changed, 22 insertions, 1 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);
}
/**