Merge pull request #3659 from dogmatic69/patch-3

simplify connect code for redis
This commit is contained in:
Mark Story 2014-06-06 10:08:36 -04:00
commit 9e744113f0

View file

@ -79,7 +79,6 @@ class RedisEngine extends CacheEngine {
* @return boolean True if Redis server was connected * @return boolean True if Redis server was connected
*/ */
protected function _connect() { protected function _connect() {
$return = false;
try { try {
$this->_Redis = new Redis(); $this->_Redis = new Redis();
if (!empty($this->settings['unix_socket'])) { if (!empty($this->settings['unix_socket'])) {
@ -91,15 +90,15 @@ class RedisEngine extends CacheEngine {
$return = $this->_Redis->pconnect($this->settings['server'], $this->settings['port'], $this->settings['timeout'], $persistentId); $return = $this->_Redis->pconnect($this->settings['server'], $this->settings['port'], $this->settings['timeout'], $persistentId);
} }
} catch (RedisException $e) { } catch (RedisException $e) {
$return = false;
}
if (!$return) {
return false; return false;
} }
if ($return && $this->settings['password']) { if ($this->settings['password'] && !$this->_Redis->auth($this->settings['password'])) {
$return = $this->_Redis->auth($this->settings['password']); return false;
} }
if ($return) { return $this->_Redis->select($this->settings['database']);
$return = $this->_Redis->select($this->settings['database']);
}
return $return;
} }
/** /**