Skip to content

Commit 76b175d

Browse files
authored
[7.x] Add support for PhpRedis 5.3 options parameter (#33799)
* fix indentation * add `context` support for PhpRedis
1 parent 44c32a2 commit 76b175d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Illuminate/Redis/Connectors/PhpRedisConnector.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ protected function createClient(array $config)
7474
return tap(new Redis, function ($client) use ($config) {
7575
if ($client instanceof RedisFacade) {
7676
throw new LogicException(
77-
extension_loaded('redis')
78-
? 'Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension.'
79-
: 'Please make sure the PHP Redis extension is installed and enabled.'
77+
extension_loaded('redis')
78+
? 'Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension.'
79+
: 'Please make sure the PHP Redis extension is installed and enabled.'
8080
);
8181
}
8282

@@ -127,6 +127,10 @@ protected function establishConnection($client, array $config)
127127
$parameters[] = Arr::get($config, 'read_timeout', 0.0);
128128
}
129129

130+
if (version_compare(phpversion('redis'), '5.3.0', '>=')) {
131+
$parameters[] = Arr::get($config, 'context', []);
132+
}
133+
130134
$client->{($persistent ? 'pconnect' : 'connect')}(...$parameters);
131135
}
132136

@@ -151,6 +155,10 @@ protected function createRedisClusterInstance(array $servers, array $options)
151155
$parameters[] = $options['password'] ?? null;
152156
}
153157

158+
if (version_compare(phpversion('redis'), '5.3.2', '>=')) {
159+
$parameters[] = Arr::get($options, 'context', []);
160+
}
161+
154162
return tap(new RedisCluster(...$parameters), function ($client) use ($options) {
155163
if (! empty($options['prefix'])) {
156164
$client->setOption(RedisCluster::OPT_PREFIX, $options['prefix']);

0 commit comments

Comments
 (0)