@@ -250,6 +250,22 @@ public static function createConnection(string $dsn, array $options = [])
250
250
$ extra = [
251
251
'stream ' => $ params ['ssl ' ] ?? null ,
252
252
];
253
+ $ booleanStreamOptions = [
254
+ 'allow_self_signed ' ,
255
+ 'capture_peer_cert ' ,
256
+ 'capture_peer_cert_chain ' ,
257
+ 'disable_compression ' ,
258
+ 'SNI_enabled ' ,
259
+ 'verify_peer ' ,
260
+ 'verify_peer_name ' ,
261
+ ];
262
+
263
+ foreach ($ extra ['stream ' ] ?? [] as $ streamOption => $ value ) {
264
+ if (\in_array ($ streamOption , $ booleanStreamOptions , true ) && \is_string ($ value )) {
265
+ $ extra ['stream ' ][$ streamOption ] = filter_var ($ value , \FILTER_VALIDATE_BOOL );
266
+ }
267
+ }
268
+
253
269
if (isset ($ params ['auth ' ])) {
254
270
$ extra ['auth ' ] = $ params ['auth ' ];
255
271
}
@@ -291,9 +307,14 @@ public static function createConnection(string $dsn, array $options = [])
291
307
} elseif (is_a ($ class , \RedisArray::class, true )) {
292
308
foreach ($ hosts as $ i => $ host ) {
293
309
switch ($ host ['scheme ' ]) {
294
- case 'tcp ' : $ hosts [$ i ] = $ host ['host ' ].': ' .$ host ['port ' ]; break ;
295
- case 'tls ' : $ hosts [$ i ] = 'tls:// ' .$ host ['host ' ].': ' .$ host ['port ' ]; break ;
296
- default : $ hosts [$ i ] = $ host ['path ' ];
310
+ case 'tcp ' :
311
+ $ hosts [$ i ] = $ host ['host ' ].': ' .$ host ['port ' ];
312
+ break ;
313
+ case 'tls ' :
314
+ $ hosts [$ i ] = 'tls:// ' .$ host ['host ' ].': ' .$ host ['port ' ];
315
+ break ;
316
+ default :
317
+ $ hosts [$ i ] = $ host ['path ' ];
297
318
}
298
319
}
299
320
$ params ['lazy_connect ' ] = $ params ['lazy ' ] ?? true ;
@@ -312,9 +333,14 @@ public static function createConnection(string $dsn, array $options = [])
312
333
$ initializer = static function () use ($ class , $ params , $ hosts ) {
313
334
foreach ($ hosts as $ i => $ host ) {
314
335
switch ($ host ['scheme ' ]) {
315
- case 'tcp ' : $ hosts [$ i ] = $ host ['host ' ].': ' .$ host ['port ' ]; break ;
316
- case 'tls ' : $ hosts [$ i ] = 'tls:// ' .$ host ['host ' ].': ' .$ host ['port ' ]; break ;
317
- default : $ hosts [$ i ] = $ host ['path ' ];
336
+ case 'tcp ' :
337
+ $ hosts [$ i ] = $ host ['host ' ].': ' .$ host ['port ' ];
338
+ break ;
339
+ case 'tls ' :
340
+ $ hosts [$ i ] = 'tls:// ' .$ host ['host ' ].': ' .$ host ['port ' ];
341
+ break ;
342
+ default :
343
+ $ hosts [$ i ] = $ host ['path ' ];
318
344
}
319
345
}
320
346
@@ -328,9 +354,15 @@ public static function createConnection(string $dsn, array $options = [])
328
354
$ redis ->setOption (\Redis::OPT_TCP_KEEPALIVE , $ params ['tcp_keepalive ' ]);
329
355
}
330
356
switch ($ params ['failover ' ]) {
331
- case 'error ' : $ redis ->setOption (\RedisCluster::OPT_SLAVE_FAILOVER , \RedisCluster::FAILOVER_ERROR ); break ;
332
- case 'distribute ' : $ redis ->setOption (\RedisCluster::OPT_SLAVE_FAILOVER , \RedisCluster::FAILOVER_DISTRIBUTE ); break ;
333
- case 'slaves ' : $ redis ->setOption (\RedisCluster::OPT_SLAVE_FAILOVER , \RedisCluster::FAILOVER_DISTRIBUTE_SLAVES ); break ;
357
+ case 'error ' :
358
+ $ redis ->setOption (\RedisCluster::OPT_SLAVE_FAILOVER , \RedisCluster::FAILOVER_ERROR );
359
+ break ;
360
+ case 'distribute ' :
361
+ $ redis ->setOption (\RedisCluster::OPT_SLAVE_FAILOVER , \RedisCluster::FAILOVER_DISTRIBUTE );
362
+ break ;
363
+ case 'slaves ' :
364
+ $ redis ->setOption (\RedisCluster::OPT_SLAVE_FAILOVER , \RedisCluster::FAILOVER_DISTRIBUTE_SLAVES );
365
+ break ;
334
366
}
335
367
336
368
return $ redis ;
@@ -387,9 +419,6 @@ public static function createConnection(string $dsn, array $options = [])
387
419
return $ redis ;
388
420
}
389
421
390
- /**
391
- * {@inheritdoc}
392
- */
393
422
protected function doFetch (array $ ids )
394
423
{
395
424
if (!$ ids ) {
@@ -423,17 +452,11 @@ protected function doFetch(array $ids)
423
452
return $ result ;
424
453
}
425
454
426
- /**
427
- * {@inheritdoc}
428
- */
429
455
protected function doHave (string $ id )
430
456
{
431
457
return (bool ) $ this ->redis ->exists ($ id );
432
458
}
433
459
434
- /**
435
- * {@inheritdoc}
436
- */
437
460
protected function doClear (string $ namespace )
438
461
{
439
462
if ($ this ->redis instanceof \Predis \ClientInterface) {
@@ -495,9 +518,6 @@ protected function doClear(string $namespace)
495
518
return $ cleared ;
496
519
}
497
520
498
- /**
499
- * {@inheritdoc}
500
- */
501
521
protected function doDelete (array $ ids )
502
522
{
503
523
if (!$ ids ) {
@@ -532,9 +552,6 @@ protected function doDelete(array $ids)
532
552
return true ;
533
553
}
534
554
535
- /**
536
- * {@inheritdoc}
537
- */
538
555
protected function doSave (array $ values , int $ lifetime )
539
556
{
540
557
if (!$ values = $ this ->marshaller ->marshall ($ values , $ failed )) {
0 commit comments