Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
Expand All @@ -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');

Expand All @@ -160,6 +163,10 @@ protected function getCacheName($cacheName)
$flush = $this->redis->get('cache:_flush');
}

if ($parameterized) {
$cacheName .= ':hset';
}

return 'cache:' . $flush . ':' . $cacheName;
}

Expand Down