From 5df245eaafa01d90910babee64a72dd22961d4b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 16 Oct 2016 19:18:17 +0200 Subject: [PATCH] Prefix keys in RedisCacheSource The RedisCacheSource allows reusing the existing server for other purposes. Prefixing the keys used by the cache avoids accidental cache smashing by plugins. --- .../system/cache/source/RedisCacheSource.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 92cdb763bd..d3ac80156f 100644 --- a/wcfsetup/install/files/lib/system/cache/source/RedisCacheSource.class.php +++ b/wcfsetup/install/files/lib/system/cache/source/RedisCacheSource.class.php @@ -58,10 +58,10 @@ class RedisCacheSource implements ICacheSource { */ public function flushAll() { // set flush key to current time if it does not exist yet (this prevents falling back to 0 if the key gets deleted) - $this->redis->setnx('_flush', TIME_NOW); + $this->redis->setnx('cache:_flush', TIME_NOW); // atomic increment of flush count - $this->redis->incr('_flush'); + $this->redis->incr('cache:_flush'); } /** @@ -141,17 +141,17 @@ class RedisCacheSource implements ICacheSource { * @return string */ protected function getCacheName($cacheName) { - $flush = $this->redis->get('_flush'); + $flush = $this->redis->get('cache:_flush'); // create flush counter if it does not exist if ($flush === false) { - $this->redis->setnx('_flush', TIME_NOW); - $this->redis->incr('_flush'); + $this->redis->setnx('cache:_flush', TIME_NOW); + $this->redis->incr('cache:_flush'); - $flush = $this->redis->get('_flush'); + $flush = $this->redis->get('cache:_flush'); } - return $flush.':'.$cacheName; + return 'cache:'.$flush.':'.$cacheName; } /** -- 2.20.1