Skip to content
Closed
Changes from all commits
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
18 changes: 18 additions & 0 deletions public/legacy/include/SugarCache/SugarCacheRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ class SugarCacheRedis extends SugarCacheAbstract
*/
protected $_port = 6379;

/**
* @var Redis password string
*/
protected $_password = '';

/**
* @var Redis database number int
*/
protected $_database = 0;

/**
* @var Redis object
*/
Expand Down Expand Up @@ -102,9 +112,17 @@ protected function _getRedisObject()
$this->_redis = new Redis();
$this->_host = SugarConfig::getInstance()->get('external_cache.redis.host', $this->_host);
$this->_port = SugarConfig::getInstance()->get('external_cache.redis.port', $this->_port);
$this->_password = SugarConfig::getInstance()->get('external_cache.redis.password', $this->_password);
$this->_database = SugarConfig::getInstance()->get('external_cache.redis.database', $this->_database);
if (!$this->_redis->connect($this->_host, $this->_port)) {
return false;
}
if (!empty($this->_password)) {
$this->_redis->auth($this->_password);
}
if ($this->_database > 0) {
$this->_redis->select($this->_database);
}
}
} catch (RedisException $e) {
return false;
Expand Down