From: Tim Düsterhus Date: Sun, 16 Oct 2016 17:18:17 +0000 (+0200) Subject: Prefix keys in RedisCacheSource X-Git-Tag: 3.0.0_Beta_3~30 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5df245eaafa01d90910babee64a72dd22961d4b2;p=GitHub%2FWoltLab%2FWCF.git 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. --- 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; } /**