|
|
@ -87,7 +87,14 @@ class MemCache extends Cache |
|
|
|
parent::init(); |
|
|
|
parent::init(); |
|
|
|
$servers = $this->getServers(); |
|
|
|
$servers = $this->getServers(); |
|
|
|
$cache = $this->getMemCache(); |
|
|
|
$cache = $this->getMemCache(); |
|
|
|
if (count($servers)) { |
|
|
|
if (empty($servers)) { |
|
|
|
|
|
|
|
$cache->addServer('127.0.0.1', 11211); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (!$this->useMemcached) { |
|
|
|
|
|
|
|
// different version of memcache may have different number of parameters for the addServer method. |
|
|
|
|
|
|
|
$class = new \ReflectionClass($cache); |
|
|
|
|
|
|
|
$paramCount = $class->getMethod('addServer')->getNumberOfParameters(); |
|
|
|
|
|
|
|
} |
|
|
|
foreach ($servers as $server) { |
|
|
|
foreach ($servers as $server) { |
|
|
|
if ($server->host === null) { |
|
|
|
if ($server->host === null) { |
|
|
|
throw new InvalidConfigException("The 'host' property must be specified for every memcache server."); |
|
|
|
throw new InvalidConfigException("The 'host' property must be specified for every memcache server."); |
|
|
@ -97,15 +104,21 @@ class MemCache extends Cache |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// $timeout is used for memcache versions that do not have timeoutms parameter |
|
|
|
// $timeout is used for memcache versions that do not have timeoutms parameter |
|
|
|
$timeout = (int) ($server->timeout / 1000) + (($server->timeout % 1000 > 0) ? 1 : 0); |
|
|
|
$timeout = (int) ($server->timeout / 1000) + (($server->timeout % 1000 > 0) ? 1 : 0); |
|
|
|
$cache->addServer( |
|
|
|
if ($paramCount === 9) { |
|
|
|
$server->host, $server->port, $server->persistent, |
|
|
|
$cache->addServer( |
|
|
|
$server->weight, $timeout, $server->retryInterval, |
|
|
|
$server->host, $server->port, $server->persistent, |
|
|
|
$server->status, $server->failureCallback, $server->timeout |
|
|
|
$server->weight, $timeout, $server->retryInterval, |
|
|
|
); |
|
|
|
$server->status, $server->failureCallback, $server->timeout |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$cache->addServer( |
|
|
|
|
|
|
|
$server->host, $server->port, $server->persistent, |
|
|
|
|
|
|
|
$server->weight, $timeout, $server->retryInterval, |
|
|
|
|
|
|
|
$server->status, $server->failureCallback |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
$cache->addServer('127.0.0.1', 11211); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|