@@ -42,6 +42,7 @@ trait RedisTrait
42
42
'redis_sentinel ' => null ,
43
43
'dbindex ' => 0 ,
44
44
'failover ' => 'none ' ,
45
+ 'ssl ' => null , // see https://php.net/context.ssl
45
46
];
46
47
private $ redis ;
47
48
private $ marshaller ;
@@ -188,7 +189,7 @@ public static function createConnection($dsn, array $options = [])
188
189
}
189
190
190
191
try {
191
- @$ redis ->{$ connect }($ host , $ port , $ params ['timeout ' ], (string ) $ params ['persistent_id ' ], $ params ['retry_interval ' ], $ params ['read_timeout ' ]);
192
+ @$ redis ->{$ connect }($ host , $ port , $ params ['timeout ' ], (string ) $ params ['persistent_id ' ], $ params ['retry_interval ' ], $ params ['read_timeout ' ], [ ' stream ' => $ params [ ' ssl ' ] ?? null ] );
192
193
193
194
set_error_handler (function ($ type , $ msg ) use (&$ error ) { $ error = $ msg ; });
194
195
$ isConnected = $ redis ->isConnected ();
@@ -251,7 +252,7 @@ public static function createConnection($dsn, array $options = [])
251
252
}
252
253
253
254
try {
254
- $ redis = new $ class (null , $ hosts , $ params ['timeout ' ], $ params ['read_timeout ' ], (bool ) $ params ['persistent ' ], $ params ['auth ' ] ?? '' );
255
+ $ redis = new $ class (null , $ hosts , $ params ['timeout ' ], $ params ['read_timeout ' ], (bool ) $ params ['persistent ' ], $ params ['auth ' ] ?? '' , $ params [ ' ssl ' ] ?? null );
255
256
} catch (\RedisClusterException $ e ) {
256
257
throw new InvalidArgumentException (sprintf ('Redis connection "%s" failed: ' , $ dsn ).$ e ->getMessage ());
257
258
}
@@ -300,7 +301,7 @@ public static function createConnection($dsn, array $options = [])
300
301
}
301
302
$ params ['exceptions ' ] = false ;
302
303
303
- $ redis = new $ class ($ hosts , array_diff_key ($ params , self ::$ defaultConnectionOptions ));
304
+ $ redis = new $ class ($ hosts , array_diff_key ($ params , array_diff_key ( self ::$ defaultConnectionOptions, [ ' ssl ' => null ]) ));
304
305
if (isset ($ params ['redis_sentinel ' ])) {
305
306
$ redis ->getConnection ()->setSentinelTimeout ($ params ['timeout ' ]);
306
307
}
@@ -547,8 +548,7 @@ private function getHosts(): array
547
548
} elseif ($ this ->redis instanceof RedisClusterProxy || $ this ->redis instanceof \RedisCluster) {
548
549
$ hosts = [];
549
550
foreach ($ this ->redis ->_masters () as $ host ) {
550
- $ hosts [] = $ h = new \Redis ();
551
- $ h ->connect ($ host [0 ], $ host [1 ]);
551
+ $ hosts [] = new RedisClusterNodeProxy ($ host , $ this ->redis );
552
552
}
553
553
}
554
554
0 commit comments