]> git.mxchange.org Git - friendica.git/commitdiff
Fix Memached config value format usage
authorHypolite Petovan <mrpetovan@gmail.com>
Sun, 8 Jul 2018 05:46:46 +0000 (01:46 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Mon, 16 Jul 2018 23:38:16 +0000 (19:38 -0400)
src/Core/Cache/MemcachedCacheDriver.php

index 870219854ab4e7b858e05f9d70c51a40b6e429ef..8b752fb3a8b8cb585566feec1913c3449f780914 100644 (file)
@@ -22,6 +22,16 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr
         */
        private $memcached;
 
+       /**
+        * Due to limitations of the INI format, the expected configuration for Memcached servers is the following:
+        * array {
+        *   0 => "hostname, port(, weight)",
+        *   1 => ...
+        * }
+        *
+        * @param array $memcached_hosts
+        * @throws \Exception
+        */
        public function __construct(array $memcached_hosts)
        {
                if (!class_exists('Memcached', false)) {
@@ -30,6 +40,10 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr
 
                $this->memcached = new Memcached();
 
+               array_walk($memcached_hosts, function (&$value) {
+                       $value = array_map('trim', explode(',', $value));
+               });
+
                $this->memcached->addServers($memcached_hosts);
 
                if (count($this->memcached->getServerList()) == 0) {