Przeglądaj źródła

#4806 Memcache distributed cache support

Alex Trofimov 2 lat temu
rodzic
commit
d316bf61f5
1 zmienionych plików z 16 dodań i 2 usunięć
  1. 16 2
      inc/classes/BxDolCacheMemcache.php

+ 16 - 2
inc/classes/BxDolCacheMemcache.php

@@ -21,8 +21,22 @@ class BxDolCacheMemcache extends BxDolCache
         parent::__construct();
         if (class_exists('Memcache')) {
             $this->oMemcache = new Memcache();
-            if (!$this->oMemcache->connect (getParam('sys_cache_memcache_host'), getParam('sys_cache_memcache_port')))
-                $this->oMemcache = null;
+            $sHost = getParam('sys_cache_memcache_host');
+            if (false === strpos($sHost, ',')) {
+                if (!$this->oMemcache->connect (getParam('sys_cache_memcache_host'), getParam('sys_cache_memcache_port')))
+                    $this->oMemcache = null;
+            } 
+            else {
+                // setting memcache.hash_strategy = consistent is recommended
+                $aHosts = explode(',', $sHost);
+                if ($aHosts) {
+                    foreach ($aHosts as $s)
+                        $this->oMemcache->addServer(trim($s), getParam('sys_cache_memcache_port'));
+                } 
+                else {
+                    $this->oMemcache = null;
+                }
+            }
         }
     }