ttl for memcache locking backends that support it
This commit is contained in:
parent
0a80bf5573
commit
693a3c353e
|
@ -28,6 +28,8 @@ use OCP\Lock\ILockingProvider;
|
||||||
* to release any left over locks at the end of the request
|
* to release any left over locks at the end of the request
|
||||||
*/
|
*/
|
||||||
abstract class AbstractLockingProvider implements ILockingProvider {
|
abstract class AbstractLockingProvider implements ILockingProvider {
|
||||||
|
const TTL = 3600; // how long until we clear stray locks in seconds
|
||||||
|
|
||||||
protected $acquiredLocks = [
|
protected $acquiredLocks = [
|
||||||
'shared' => [],
|
'shared' => [],
|
||||||
'exclusive' => []
|
'exclusive' => []
|
||||||
|
|
|
@ -51,8 +51,6 @@ class DBLockingProvider extends AbstractLockingProvider {
|
||||||
|
|
||||||
private $sharedLocks = [];
|
private $sharedLocks = [];
|
||||||
|
|
||||||
const TTL = 3600; // how long until we clear stray locks in seconds
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we have an open shared lock for a path
|
* Check if we have an open shared lock for a path
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace OC\Lock;
|
namespace OC\Lock;
|
||||||
|
|
||||||
|
use OCP\IMemcacheTTL;
|
||||||
use OCP\Lock\LockedException;
|
use OCP\Lock\LockedException;
|
||||||
use OCP\IMemcache;
|
use OCP\IMemcache;
|
||||||
|
|
||||||
|
@ -37,6 +38,12 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
|
||||||
$this->memcache = $memcache;
|
$this->memcache = $memcache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setTTL($path) {
|
||||||
|
if ($this->memcache instanceof IMemcacheTTL) {
|
||||||
|
$this->memcache->setTTL($path, self::TTL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
|
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
|
||||||
|
@ -69,6 +76,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
|
||||||
throw new LockedException($path);
|
throw new LockedException($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->setTTL($path);
|
||||||
$this->markAcquire($path, $type);
|
$this->markAcquire($path, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +114,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
|
||||||
throw new LockedException($path);
|
throw new LockedException($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->setTTL($path);
|
||||||
$this->markChange($path, $targetType);
|
$this->markChange($path, $targetType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue