Skip to content

Commit

Permalink
RedisEngine: authenticate connection if 'password' is set
Browse files Browse the repository at this point in the history
  • Loading branch information
rchavik committed Nov 2, 2012
1 parent 0196c6f commit 7d84486
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Cache/Cache.php
Expand Up @@ -103,7 +103,7 @@ class Cache {
* - `path` Used by FileCache. Path to where cachefiles should be saved.
* - `lock` Used by FileCache. Should files be locked before writing to them?
* - `user` Used by Xcache. Username for XCache
* - `password` Used by Xcache. Password for XCache
* - `password` Used by Xcache/Redis. Password for XCache/Redis
*
* @see app/Config/core.php for configuration settings
* @param string $name Name of the configuration
Expand Down
4 changes: 4 additions & 0 deletions lib/Cake/Cache/Engine/RedisEngine.php
Expand Up @@ -62,6 +62,7 @@ public function init($settings = array()) {
'prefix' => null,
'server' => '127.0.0.1',
'port' => 6379,
'password' => false,
'timeout' => 0,
'persistent' => true
), $settings)
Expand All @@ -87,6 +88,9 @@ protected function _connect() {
} catch (RedisException $e) {
return false;
}
if ($return && $this->settings['password']) {
$return = $this->_Redis->auth($this->settings['password']);
}
return $return;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Test/Case/Cache/Engine/RedisEngineTest.php
Expand Up @@ -73,7 +73,8 @@ public function testSettings() {
'server' => '127.0.0.1',
'port' => 6379,
'timeout' => 0,
'persistent' => true
'persistent' => true,
'password' => false,
);
$this->assertEquals($expecting, $settings);
}
Expand Down

0 comments on commit 7d84486

Please sign in to comment.