@@ -223,29 +223,28 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra
223
223
break ;
224
224
}
225
225
226
- if (version_compare (phpversion ('redis ' ), '6.0.0 ' , '>= ' ) && $ isRedisExt ) {
227
- $ options = [
228
- 'host ' => $ host ,
229
- 'port ' => $ port ,
230
- 'connectTimeout ' => $ params ['timeout ' ],
231
- 'persistent ' => $ params ['persistent_id ' ],
232
- 'retryInterval ' => $ params ['retry_interval ' ],
233
- 'readTimeout ' => $ params ['read_timeout ' ],
234
- ];
235
-
236
- if ($ passAuth ) {
237
- $ options ['auth ' ] = $ params ['auth ' ];
226
+ try {
227
+ if (version_compare (phpversion ('redis ' ), '6.0.0 ' , '>= ' ) && $ isRedisExt ) {
228
+ $ options = [
229
+ 'host ' => $ host ,
230
+ 'port ' => $ port ,
231
+ 'connectTimeout ' => $ params ['timeout ' ],
232
+ 'persistent ' => $ params ['persistent_id ' ],
233
+ 'retryInterval ' => $ params ['retry_interval ' ],
234
+ 'readTimeout ' => $ params ['read_timeout ' ],
235
+ ];
236
+
237
+ if ($ passAuth ) {
238
+ $ options ['auth ' ] = $ params ['auth ' ];
239
+ }
240
+
241
+ $ sentinel = new \RedisSentinel ($ options );
242
+ } else {
243
+ $ extra = $ passAuth ? [$ params ['auth ' ]] : [];
244
+
245
+ $ sentinel = new $ sentinelClass ($ host , $ port , $ params ['timeout ' ], (string ) $ params ['persistent_id ' ], $ params ['retry_interval ' ], $ params ['read_timeout ' ], ...$ extra );
238
246
}
239
247
240
- $ sentinel = new \RedisSentinel ($ options );
241
- } else {
242
- $ extra = $ passAuth ? [$ params ['auth ' ]] : [];
243
-
244
- $ sentinel = new $ sentinelClass ($ host , $ port , $ params ['timeout ' ], (string ) $ params ['persistent_id ' ], $ params ['retry_interval ' ], $ params ['read_timeout ' ], ...$ extra );
245
- }
246
-
247
- try {
248
- $ sentinel = new $ sentinelClass ($ host , $ port , $ params ['timeout ' ], (string ) $ params ['persistent_id ' ], $ params ['retry_interval ' ], $ params ['read_timeout ' ], ...$ extra );
249
248
if ($ address = $ sentinel ->getMasterAddrByName ($ params ['redis_sentinel ' ])) {
250
249
[$ host , $ port ] = $ address ;
251
250
}
0 commit comments