diff --git a/public/legacy/include/SugarCache/SugarCacheRedis.php b/public/legacy/include/SugarCache/SugarCacheRedis.php index 9d7236a4d5..e157baaf9c 100755 --- a/public/legacy/include/SugarCache/SugarCacheRedis.php +++ b/public/legacy/include/SugarCache/SugarCacheRedis.php @@ -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 */ @@ -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;