Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added REDIS cache configuration property ("username") in cache config… #4569

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions framework/caching/CRedisCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* 'port'=>6379,
* 'database'=>0,
* 'options'=>STREAM_CLIENT_CONNECT,
* 'username' => 'default' // only for REDIS version 6.0 or later
* ),
* ),
* )
Expand All @@ -52,6 +53,10 @@ class CRedisCache extends CCache
* @var int the port to use for connecting to the redis server. Default port is 6379.
*/
public $port=6379;
/**
* @var string the username to use to authenticate with the redis server. If set, AUTH command will be sent with username.
*/
samdark marked this conversation as resolved.
Show resolved Hide resolved
public $username;
/**
* @var string the password to use to authenticate with the redis server. If not set, no AUTH command will be sent.
*/
Expand Down Expand Up @@ -96,8 +101,13 @@ protected function connect()
{
if($this->ssl)
stream_socket_enable_crypto($this->_socket,true,STREAM_CRYPTO_METHOD_TLS_CLIENT);
if($this->password!==null)
$this->executeCommand('AUTH',array($this->password));
if($this->password!==null || $this->username!==null){
if(isset($this->username))
arfeen marked this conversation as resolved.
Show resolved Hide resolved
$this->executeCommand('AUTH',array($this->username, $this->password));
else
$this->executeCommand('AUTH',array($this->password));
}

$this->executeCommand('SELECT',array($this->database));
}
else
Expand Down
Loading