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