Skip to content

Commit

Permalink
Merge branch '6.3' into 6.4
Browse files Browse the repository at this point in the history
* 6.3:
  [Messenger] Fix support for Redis Sentinel using php-redis 6.0.0
  • Loading branch information
nicolas-grekas committed Nov 21, 2023
2 parents ecbe52e + 43a1fa1 commit 584af8d
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,21 @@ public function __construct(array $options, \Redis|Relay|\RedisCluster $redis =
}

try {
$sentinel = new $sentinelClass($host, $port, $options['timeout'], $options['persistent_id'], $options['retry_interval'], $options['read_timeout']);
if (\extension_loaded('redis') && version_compare(phpversion('redis'), '6.0.0', '>=')) {
$params = [
'host' => $host,
'port' => $port,
'connectTimeout' => $options['timeout'],
'persistent' => $options['persistent_id'],
'retryInterval' => $options['retry_interval'],
'readTimeout' => $options['read_timeout'],
];

$sentinel = new \RedisSentinel($params);
} else {
$sentinel = new $sentinelClass($host, $port, $options['timeout'], $options['persistent_id'], $options['retry_interval'], $options['read_timeout']);
}

if ($address = $sentinel->getMasterAddrByName($sentinelMaster)) {
[$host, $port] = $address;
}
Expand Down

0 comments on commit 584af8d

Please sign in to comment.