Fixed Memcached implementation
authorAlexander Ebert <ebert@woltlab.com>
Sun, 27 Jan 2013 14:56:35 +0000 (15:56 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 27 Jan 2013 14:56:35 +0000 (15:56 +0100)
Thanks to @TimWolla

wcfsetup/install/files/lib/system/cache/source/MemcachedAdapter.class.php
wcfsetup/install/files/lib/system/cache/source/MemcachedCacheSource.class.php

index 36e235bd31c84892f91579e72dc17644cc2f68c5..357b395d46905937c5796b901a4a8c3cca8a0990 100644 (file)
@@ -31,7 +31,7 @@ class MemcachedAdapter extends SingletonFactory {
                
                // init memcached
                if (CACHE_SOURCE_MEMCACHED_USE_PCONNECT) {
-                       $this->memcached = new \Memcached('wcf_memcached');
+                       $this->memcached = new \Memcached('wcf'.WCF_N.'_memcached');
                }
                else {
                        $this->memcached = new \Memcached();
index 16d7fe19fc40d04decee7b766f879db7480aa5a2..c7d9d07fd2553f5c6ecd7a28ce864277299f5a9b 100644 (file)
@@ -48,7 +48,7 @@ class MemcachedCacheSource implements ICacheSource {
        /**
         * Returns the memcached adapter.
         * 
-        * @return      \MemcachedAdapter
+        * @return      wcf\system\cache\source\MemcachedAdapter
         */
        public function getAdapter() {
                return $this->adapter;
@@ -127,7 +127,13 @@ class MemcachedCacheSource implements ICacheSource {
         */
        public function get(array $cacheResource) {
                $value = $this->getAdapter()->getMemcached()->get($cacheResource['file']);
-               if ($value === false) return null;
+               if ($value === false) {
+                       // check if result code if return values is a boolean value instead of no result
+                       if ($this->getAdapter()->getMemcached()->getResultCode() == \Memcached::RES_NOTFOUND) {
+                               return null;
+                       }
+               }
+               
                return $value;
        }