diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-12-09 14:41:15 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-12-09 14:41:15 +0100 |
commit | 693a3c353ef88df2372426d4d1ea9f6527a59d62 (patch) | |
tree | b1376971f51f8ccc2750ab09c359ebbc7b97dfaf /lib/private/lock | |
parent | 0a80bf55739ef9d30cfef376377f5c54dd5a9a9c (diff) | |
download | nextcloud-server-693a3c353ef88df2372426d4d1ea9f6527a59d62.tar.gz nextcloud-server-693a3c353ef88df2372426d4d1ea9f6527a59d62.zip |
ttl for memcache locking backends that support it
Diffstat (limited to 'lib/private/lock')
-rw-r--r-- | lib/private/lock/abstractlockingprovider.php | 2 | ||||
-rw-r--r-- | lib/private/lock/dblockingprovider.php | 2 | ||||
-rw-r--r-- | lib/private/lock/memcachelockingprovider.php | 9 |
3 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/lock/abstractlockingprovider.php b/lib/private/lock/abstractlockingprovider.php index c7a29380efe..db5f1c72dd7 100644 --- a/lib/private/lock/abstractlockingprovider.php +++ b/lib/private/lock/abstractlockingprovider.php @@ -28,6 +28,8 @@ use OCP\Lock\ILockingProvider; * to release any left over locks at the end of the request */ abstract class AbstractLockingProvider implements ILockingProvider { + const TTL = 3600; // how long until we clear stray locks in seconds + protected $acquiredLocks = [ 'shared' => [], 'exclusive' => [] diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php index 90657e6725f..b3a12bb9a07 100644 --- a/lib/private/lock/dblockingprovider.php +++ b/lib/private/lock/dblockingprovider.php @@ -51,8 +51,6 @@ class DBLockingProvider extends AbstractLockingProvider { 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 * diff --git a/lib/private/lock/memcachelockingprovider.php b/lib/private/lock/memcachelockingprovider.php index e4158dcdfdf..af95200d159 100644 --- a/lib/private/lock/memcachelockingprovider.php +++ b/lib/private/lock/memcachelockingprovider.php @@ -21,6 +21,7 @@ namespace OC\Lock; +use OCP\IMemcacheTTL; use OCP\Lock\LockedException; use OCP\IMemcache; @@ -37,6 +38,12 @@ class MemcacheLockingProvider extends AbstractLockingProvider { $this->memcache = $memcache; } + private function setTTL($path) { + if ($this->memcache instanceof IMemcacheTTL) { + $this->memcache->setTTL($path, self::TTL); + } + } + /** * @param string $path * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE @@ -69,6 +76,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { throw new LockedException($path); } } + $this->setTTL($path); $this->markAcquire($path, $type); } @@ -106,6 +114,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { throw new LockedException($path); } } + $this->setTTL($path); $this->markChange($path, $targetType); } } |