Skip to content

Commit

Permalink
simplify connect code for redis
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jun 6, 2014
1 parent 91224b0 commit 4a4a357
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/Cake/Cache/Engine/RedisEngine.php
Expand Up @@ -79,7 +79,6 @@ public function init($settings = array()) {
* @return boolean True if Redis server was connected
*/
protected function _connect() {
$return = false;
try {
$this->_Redis = new Redis();
if (!empty($this->settings['unix_socket'])) {
Expand All @@ -91,15 +90,15 @@ protected function _connect() {
$return = $this->_Redis->pconnect($this->settings['server'], $this->settings['port'], $this->settings['timeout'], $persistentId);
}
} catch (RedisException $e) {
return false;
$return = false;
}
if ($return && $this->settings['password']) {
$return = $this->_Redis->auth($this->settings['password']);
if (!$return) {
return false;
}
if ($return) {
$return = $this->_Redis->select($this->settings['database']);
if ($this->settings['password'] && !$this->_Redis->auth($this->settings['password'])) {
return false;
}
return $return;
return $this->_Redis->select($this->settings['database']);
}

/**
Expand Down

0 comments on commit 4a4a357

Please sign in to comment.