Skip to content

Commit

Permalink
Add username to auth params
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftedreality committed Aug 11, 2022
1 parent f5d8553 commit 933c6ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Cm/Cache/Backend/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ protected function getClientOptions($options = array())
$clientOptions->connectRetries = isset($options['connect_retries']) ? (int) $options['connect_retries'] : self::DEFAULT_CONNECT_RETRIES;
$clientOptions->readTimeout = isset($options['read_timeout']) ? (float) $options['read_timeout'] : NULL;
$clientOptions->password = isset($options['password']) ? $options['password'] : NULL;
$clientOptions->username = isset($options['username']) ? $options['username'] : NULL;
$clientOptions->database = isset($options['database']) ? (int) $options['database'] : 0;
$clientOptions->persistent = isset($options['persistent']) ? $options['persistent'] : '';
$clientOptions->timeout = isset($options['timeout']) ? $options['timeout'] : self::DEFAULT_CONNECT_TIMEOUT;
Expand Down Expand Up @@ -420,7 +421,11 @@ protected function _applyClientOptions(Credis_Client $client, $forceSelect = FAL
}

if ($clientOptions->password) {
$client->auth($clientOptions->password) or Zend_Cache::throwException('Unable to authenticate with the redis server.');
if ($clientOptions->username) {
$client->auth($clientOptions->password, $clientOptions->username) or Zend_Cache::throwException('Unable to authenticate with the redis server.');
} else {
$client->auth($clientOptions->password) or Zend_Cache::throwException('Unable to authenticate with the redis server.');
}
}

// Always select database when persistent is used in case connection is re-used by other clients
Expand Down

0 comments on commit 933c6ab

Please sign in to comment.