Skip to content

Commit

Permalink
Added the ability to force use RedisCluster in Messenger
Browse files Browse the repository at this point in the history
Previously, an array had to be specified to support a cluster. But the nodes can change. Instead of "redis://host-0,redis://host-1" we specify "redis://server?redis_cluster=true"
  • Loading branch information
adideas committed May 8, 2024
1 parent 5a00a8b commit 6a26072
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Connection
'retry_interval' => 0, // Int, value in milliseconds (optional, default is 0)
'persistent_id' => null, // String, persistent connection id (optional, default is NULL meaning not persistent)
'ssl' => null, // see https://php.net/context.ssl
'redis_cluster' => false, // force use of cluster
];

private \Redis|Relay|\RedisCluster|\Closure $redis;
Expand Down Expand Up @@ -110,7 +111,7 @@ public function __construct(array $options, \Redis|Relay|\RedisCluster|null $red
}
}

if ((\is_array($host) && null === $sentinelMaster) || $redis instanceof \RedisCluster) {
if ((\is_array($host) && null === $sentinelMaster) || $redis instanceof \RedisCluster || $options['redis_cluster']) {
$hosts = \is_string($host) ? [$host.':'.$port] : $host; // Always ensure we have an array
$this->redis = static fn () => self::initializeRedisCluster($redis, $hosts, $auth, $options);
} else {
Expand Down

0 comments on commit 6a26072

Please sign in to comment.