diff options
author | Robin Appelman <robin@icewind.nl> | 2023-03-29 18:03:03 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2023-12-21 15:14:27 +0100 |
commit | 7394645eb7f2f1d2831bb7c106737087992e4da4 (patch) | |
tree | 34012ad67f80abc7fee1d730cacbfd6c5cc02334 /lib/private/Memcache | |
parent | 0dcea036a7d8ce7b078d051c1752971ddef0473f (diff) | |
download | nextcloud-server-7394645eb7f2f1d2831bb7c106737087992e4da4.tar.gz nextcloud-server-7394645eb7f2f1d2831bb7c106737087992e4da4.zip |
restore shared lock ttl when releasing
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Memcache')
-rw-r--r-- | lib/private/Memcache/LoggerWrapperCache.php | 10 | ||||
-rw-r--r-- | lib/private/Memcache/ProfilerWrapperCache.php | 10 | ||||
-rw-r--r-- | lib/private/Memcache/Redis.php | 17 |
3 files changed, 35 insertions, 2 deletions
diff --git a/lib/private/Memcache/LoggerWrapperCache.php b/lib/private/Memcache/LoggerWrapperCache.php index 55c0e76db79..55d5104dedb 100644 --- a/lib/private/Memcache/LoggerWrapperCache.php +++ b/lib/private/Memcache/LoggerWrapperCache.php @@ -167,10 +167,18 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ - public function setTTL($key, $ttl) { + public function setTTL(string $key, int $ttl) { $this->wrappedCache->setTTL($key, $ttl); } + public function getTTL(string $key): int|false { + return $this->wrappedCache->getTTL($key); + } + + public function compareSetTTL(string $key, mixed $value, int $ttl): bool { + return $this->wrappedCache->compareSetTTL($key, $value, $ttl); + } + public static function isAvailable(): bool { return true; } diff --git a/lib/private/Memcache/ProfilerWrapperCache.php b/lib/private/Memcache/ProfilerWrapperCache.php index 6e76989dddd..a5cb667114c 100644 --- a/lib/private/Memcache/ProfilerWrapperCache.php +++ b/lib/private/Memcache/ProfilerWrapperCache.php @@ -183,10 +183,18 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ - public function setTTL($key, $ttl) { + public function setTTL(string $key, int $ttl) { $this->wrappedCache->setTTL($key, $ttl); } + public function getTTL(string $key): int|false { + return $this->wrappedCache->getTTL($key); + } + + public function compareSetTTL(string $key, mixed $value, int $ttl): bool { + return $this->wrappedCache->compareSetTTL($key, $value, $ttl); + } + public function offsetExists($offset): bool { return $this->hasKey($offset); } diff --git a/lib/private/Memcache/Redis.php b/lib/private/Memcache/Redis.php index bde25a3385a..7bd29d1cecf 100644 --- a/lib/private/Memcache/Redis.php +++ b/lib/private/Memcache/Redis.php @@ -181,6 +181,23 @@ class Redis extends Cache implements IMemcacheTTL { $this->getCache()->expire($this->getPrefix() . $key, $ttl); } + public function getTTL(string $key): int|false { + $ttl = $this->getCache()->ttl($this->getPrefix() . $key); + return $ttl > 0 ? (int)$ttl : false; + } + + public function compareSetTTL(string $key, mixed $value, int $ttl): bool { + $fullKey = $this->getPrefix() . $key; + $redis = $this->getCache(); + if ($this->get($key) === $value) { + $result = $redis->multi() + ->expire($fullKey, $ttl) + ->exec(); + return $result !== false; + } + return false; + } + public static function isAvailable(): bool { return \OC::$server->getGetRedisFactory()->isAvailable(); } |