diff --git a/wcfsetup/install/files/lib/system/cache/source/RedisCacheSource.class.php b/wcfsetup/install/files/lib/system/cache/source/RedisCacheSource.class.php index c33f966f1f1..b528e422496 100644 --- a/wcfsetup/install/files/lib/system/cache/source/RedisCacheSource.class.php +++ b/wcfsetup/install/files/lib/system/cache/source/RedisCacheSource.class.php @@ -46,10 +46,13 @@ public function flush($cacheName, $useWildcard) if (isset($parts[1])) { if ($useWildcard) { // delete the complete hashset - $this->redis->del($this->getCacheName($parts[0])); + $this->redis->del( + $this->getCacheName($parts[0], true), + $this->getCacheName($parts[0]), + ); } else { // delete the specified key from the hashset - $this->redis->hDel($this->getCacheName($parts[0]), $parts[1]); + $this->redis->hDel($this->getCacheName($parts[0], true), $parts[1]); } } else { $this->redis->del($this->getCacheName($cacheName)); @@ -77,7 +80,7 @@ public function get($cacheName, $maxLifetime) $parts = \explode('-', $cacheName, 2); if (isset($parts[1])) { - $value = $this->redis->hGet($this->getCacheName($parts[0]), $parts[1]); + $value = $this->redis->hGet($this->getCacheName($parts[0], true), $parts[1]); } else { $value = $this->redis->get($this->getCacheName($cacheName)); } @@ -123,7 +126,7 @@ public function set($cacheName, $value, $maxLifetime) // check if entry is parameterized if (isset($parts[1])) { - $key = $this->getCacheName($parts[0]); + $key = $this->getCacheName($parts[0], true); // save parameterized cache entries as field in a hashset // saving in a hashset is safe as the smallest lifetime of its fields is set as TTL for the whole hashset @@ -148,7 +151,7 @@ public function set($cacheName, $value, $maxLifetime) * @param string $cacheName * @return string */ - protected function getCacheName($cacheName) + protected function getCacheName($cacheName, bool $parameterized = false) { $flush = $this->redis->get('cache:_flush'); @@ -160,6 +163,10 @@ protected function getCacheName($cacheName) $flush = $this->redis->get('cache:_flush'); } + if ($parameterized) { + $cacheName .= ':hset'; + } + return 'cache:' . $flush . ':' . $cacheName; }