Implement RedisCacheSource::get()
authorMaximilian Mader <max@bastelstu.be>
Wed, 31 Dec 2014 16:02:11 +0000 (17:02 +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 e9ec4c7b99f2bfa66ac527bb3d2452e90ee7ad16..209d181c2724613272518990a641149661fa133b 100644 (file)
@@ -99,7 +99,28 @@ class RedisCacheSource implements ICacheSource {
         * @see \wcf\system\cache\source\ICacheSource::get()
         */
        public function get($cacheName, $maxLifetime) {
+               $parts = explode('-', $cacheName, 2);
+               
+               if (isset($parts[1])) {
+                       $value = $this->redis->hget($this->getCacheName($parts[0]), $parts[1]);
+               }
+               else {
+                       $value = $this->redis->get($this->getCacheName($cacheName));
+               }
+               
+               // check if the key exist
+               if ($value === false) {
+                       return null;
+               }
+               
+               $value = @unserialize($value);
+               
+               // check if value is valid
+               if ($value === false) {
+                       return null;
+               }
                
+               return $value;
        }
        
        /**