From 10bb2f121450eacea7e69ed7eda6ddd312ed89f6 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Wed, 31 Dec 2014 16:57:42 +0100 Subject: [PATCH] Implement RedisCacheSource::getCacheName() --- .../cache/source/RedisCacheSource.class.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 a1ee065cb0..aac947eab8 100644 --- a/wcfsetup/install/files/lib/system/cache/source/RedisCacheSource.class.php +++ b/wcfsetup/install/files/lib/system/cache/source/RedisCacheSource.class.php @@ -113,4 +113,24 @@ class RedisCacheSource implements ICacheSource { $this->redis->setex($cacheName, $this->getTTL($maxLifetime), serialize($value)); } } + + /** + * Returns the name for the given cache name in respect to flush count. + * + * @param string $cacheName + * @return string + */ + protected function getCacheName($cacheName) { + $flush = $this->redis->get('_flush'); + + // create flush counter if it does not exist + if ($flush === false) { + $this->redis->setnx('_flush', TIME_NOW); + $this->redis->incr('_flush'); + + $flush = $this->redis->get('_flush'); + } + + return $flush.':'.$cacheName; + } } -- 2.20.1