为cache中的memcached增加连接时账号密码的属性

可以连接带有密账号密码验证的memcached了
This commit is contained in:
zzpuser
2016-07-01 23:31:29 +08:00
committed by GitHub
parent 2cb8022982
commit 4b190f9111

View File

@@ -23,6 +23,8 @@ class Memcached
'expire' => 0,
'timeout' => 0, // 超时时间(单位:毫秒)
'prefix' => '',
'username' => '', //账号
'password' => '', //密码
];
/**
@@ -55,6 +57,10 @@ class Memcached
$servers[] = [$host, (isset($ports[$i]) ? $ports[$i] : $ports[0]), 1];
}
$this->handler->addServers($servers);
if('' != $this->options['username']){
$this->handler->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
$this->handler->setSaslAuthData($this->options['username'], $this->options['password']);
}
}
/**