Commit 6c60ace1 authored by anupamadharmajan's avatar anupamadharmajan Committed by Robert Lyon
Browse files

Bug 1876185: Allow redis function without needing sentinel

behatnotneeded

Change-Id: Ie3bdf87e55eba107d57eaade2e4d5c9c2d98ca37
parent d6179a83
......@@ -718,11 +718,21 @@ function is_redis_configured() {
function get_redis_master() {
$master = null;
foreach (get_redis_servers() as $server) {
if (!empty($server['server']) && !empty($server['mastergroup']) && !empty($server['prefix'])) {
require_once(get_config('libroot') . 'redis/sentinel.php');
$sentinel = new sentinel($server['server']);
$master = $sentinel->get_master_addr($server['mastergroup']);
if ($redisserver = get_config('redisserver')) {
// Skipping REDIS SENTINEL master interrogation if redisserver variable configured in config.php.
$master = new \stdClass();
list($redisserverhost, $redisserverport) = explode(':', $redisserver);
$master->ip = $redisserverhost;
$master->port = $redisserverport;
}
else {
foreach (get_redis_servers() as $server) {
if (!empty($server['server']) && !empty($server['mastergroup']) && !empty($server['prefix'])) {
require_once(get_config('libroot') . 'redis/sentinel.php');
$sentinel = new sentinel($server['server']);
$master = $sentinel->get_master_addr($server['mastergroup']);
}
}
}
......@@ -730,11 +740,11 @@ function get_redis_master() {
}
function get_redis_servers() {
$redissentinelservers = get_config('redissentinelservers');
$redisserver = get_config('redisserver') ? get_config('redisserver') : get_config('redissentinelservers');
$redismastergroup = get_config('redismastergroup');
$redisprefix = get_config('redisprefix');
$redis_servers[] = array(
'server' => $redissentinelservers,
'server' => $redisserver,
'mastergroup' => $redismastergroup,
'prefix' => $redisprefix
);
......
......@@ -749,9 +749,12 @@ $cfg->sessionhandler = 'file';
/**
* Redis session handling
*/
// If accessing a redis sentinel server
//$cfg->redissentinelservers = "localhost:26379"; // A comma seperated string of hosts:ports
//$cfg->redismastergroup = 'mymaster';
//$cfg->redisprefix = 'mahara';
// Otherwise use direct redis connection
//$cfg->redisserver = "localhost:26379"; // A string of a single host:port
/**
* SQL session store configs for SimpleSAMLphp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment