Fix Memached config value format usage
This commit is contained in:
parent
8fe9a46ccf
commit
6b03ae92b8
1 changed files with 14 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue