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; }