Implement RedisCacheSource::getCacheName()
authorMaximilian Mader <max@bastelstu.be>
Wed, 31 Dec 2014 15:57:42 +0000 (16:57 +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 a1ee065cb02506aedaae40672634e23244efe198..aac947eab8d329f29a3fccb69c40cb1bf02efdb4 100644 (file)
@@ -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;
+       }
 }