支持集成环境

This commit is contained in:
huangdijia
2015-04-13 14:28:36 +08:00
parent 7bb958636e
commit ba213bfcbe

View File

@@ -40,9 +40,16 @@ class Memcache {
} }
$func = $this->options['persistent'] ? 'pconnect' : 'connect'; $func = $this->options['persistent'] ? 'pconnect' : 'connect';
$this->handler = new \Memcache; $this->handler = new \Memcache;
$options['timeout'] === false ? // 支持集群
$this->handler->$func($options['host'], $options['port']) : $hosts = explode(',', $this->options['host']);
$this->handler->$func($options['host'], $options['port'], $options['timeout']); $ports = explode(',', $this->options['port']);
foreach((array) $hosts as $i=>$host){
$port = isset($ports[$i]) ? $ports[$i] : $ports[0];
$options['timeout'] === false ?
$this->handler->addServer($host, $port, $this->options['persistent'], 1) :
$this->handler->addServer($host, $port, $this->options['persistent'], 1, $this->options['timeout']);
}
} }
/** /**