Implement RedisCacheSource::flush()
authorMaximilian Mader <max@bastelstu.be>
Wed, 31 Dec 2014 15:59:59 +0000 (16:59 +0100)
committerMaximilian Mader <max@bastelstu.be>
Fri, 29 May 2015 01:49:01 +0000 (03:49 +0200)
wcfsetup/install/files/lib/system/cache/source/RedisCacheSource.class.php

index 597f2fb233a692c8572a4064c5119b1d8d826412..b12c5785037be6f5f9e3e67366bf62ed58f6a366 100644 (file)
@@ -66,7 +66,22 @@ class RedisCacheSource implements ICacheSource {
         * @see \wcf\system\cache\source\ICacheSource::flush()
         */
        public function flush($cacheName, $useWildcard) {
+               $parts = explode('-', $cacheName, 2);
                
+               // check if the key is saved in a hashset
+               if (isset($parts[1])) {
+                       if ($useWildcard) {
+                               // delete the complete hashset
+                               $this->redis->del($this->getCacheName($parts[0]));
+                       }
+                       else {
+                               // delete the specified key from the hashset
+                               $this->redis->hdel($this->getCacheName($parts[0]), $parts[1]);
+                       }
+               }
+               else {
+                       $this->redis->del($this->getCacheName($cacheName));
+               }
        }
        
        /**