From 542fb953811099c4637c994ccf9d76652a908bc7 Mon Sep 17 00:00:00 2001 From: "arpad.horvath" Date: Mon, 13 Nov 2023 14:34:09 +0100 Subject: [PATCH] - update memcached connect --- src/Illuminate/Cache/MemcachedConnector.php | 25 ++++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Illuminate/Cache/MemcachedConnector.php b/src/Illuminate/Cache/MemcachedConnector.php index e860c07..e4073df 100644 --- a/src/Illuminate/Cache/MemcachedConnector.php +++ b/src/Illuminate/Cache/MemcachedConnector.php @@ -19,17 +19,20 @@ public function connect(array $servers) // For each server in the array, we'll just extract the configuration and add // the server to the Memcached connection. Once we have added all of these // servers we'll verify the connection is successful and return it back. - foreach ($servers as $server) - { - $memcached->addServer( - $server['host'], $server['port'], $server['weight'] - ); - } - - if ($memcached->getVersion() === false) - { - throw new \RuntimeException("Could not establish Memcached connection."); - } + $serverlist = array(); + foreach ($servers as $server) + { + $memcached->addServer( + $server['host'], $server['port'], $server['weight'] + ); + + if ($memcached->getVersion() !== false) + { + $serverlist[] = [$server['host'], $server['port'], $server['weight']]; + } + $memcached->resetServerList(); + } + $memcached->addServers($serverlist); return $memcached; }