- Enh #4520: yii\caching/MemCache.php add sasl support (xjflyttp)

This commit is contained in:
xjflyttp
2014-07-31 20:42:59 +08:00
parent 68fafdb440
commit c5fbf89b44
2 changed files with 16 additions and 0 deletions

View File

@ -83,6 +83,17 @@ class MemCache extends Cache
*/
public $options;
/**
* @var string memcached sasl username
* @see http://php.net/manual/en/memcached.setsaslauthdata.php
*/
public $username;
/**
* @var string memcached sasl password
* @see http://php.net/manual/en/memcached.setsaslauthdata.php
*/
public $password;
/**
* @var \Memcache|\Memcached the Memcache instance
*/
@ -201,6 +212,10 @@ class MemCache extends Cache
if ($this->useMemcached) {
$this->_cache = $this->persistentId !== null ? new \Memcached($this->persistentId) : new \Memcached;
if ($this->username !== null || $this->password !== null) {
$this->_cache->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
$this->_cache->setSaslAuthData($this->username, $this->password);
}
if (!empty($this->options)) {
$this->_cache->setOptions($this->options);
}