Merge pull request #2725 from nextcloud/memcached-connect-once

[downstream] Set options, then add servers
This commit is contained in:
Roeland Jago Douma 2016-12-17 19:31:31 +01:00 committed by GitHub
commit a60479a3d3
1 changed files with 11 additions and 10 deletions

View File

@ -46,16 +46,6 @@ class Memcached extends Cache implements IMemcache {
parent::__construct($prefix); parent::__construct($prefix);
if (is_null(self::$cache)) { if (is_null(self::$cache)) {
self::$cache = new \Memcached(); self::$cache = new \Memcached();
$servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
if (!$servers) {
$server = \OC::$server->getSystemConfig()->getValue('memcached_server');
if ($server) {
$servers = array($server);
} else {
$servers = array(array('localhost', 11211));
}
}
self::$cache->addServers($servers);
$defaultOptions = [ $defaultOptions = [
\Memcached::OPT_CONNECT_TIMEOUT => 50, \Memcached::OPT_CONNECT_TIMEOUT => 50,
@ -85,6 +75,17 @@ class Memcached extends Cache implements IMemcache {
} else { } else {
throw new HintException("Expected 'memcached_options' config to be an array, got $options"); throw new HintException("Expected 'memcached_options' config to be an array, got $options");
} }
$servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
if (!$servers) {
$server = \OC::$server->getSystemConfig()->getValue('memcached_server');
if ($server) {
$servers = [$server];
} else {
$servers = [['localhost', 11211]];
}
}
self::$cache->addServers($servers);
} }
} }