@@ -48,6 +48,7 @@ trait RedisTrait
48
48
'lazy ' => null ,
49
49
'redis_cluster ' => false ,
50
50
'relay_cluster ' => false ,
51
+ 'relay_cluster_context ' => [],
51
52
'redis_sentinel ' => null ,
52
53
'dbindex ' => 0 ,
53
54
'failover ' => 'none ' ,
@@ -377,14 +378,34 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra
377
378
}
378
379
379
380
try {
381
+ $ relayClusterContext = $ params ['relay_cluster_context ' ];
382
+
383
+ foreach (['allow_self_signed ' , 'verify_peer_name ' ,'verify_peer ' ] as $ contextStreamBoolField ) {
384
+ if (isset ($ relayClusterContext ['stream ' ][$ contextStreamBoolField ])) {
385
+ $ relayClusterContext ['stream ' ][$ contextStreamBoolField ] = filter_var ($ relayClusterContext ['stream ' ][$ contextStreamBoolField ], \FILTER_VALIDATE_BOOL );
386
+ }
387
+ }
388
+
389
+ foreach (['use-cache ' , 'client-tracking ' ,'throw-on-error ' ,'client-invalidations ' ,'reply-literal ' ,'persistent ' ] as $ contextBoolField ) {
390
+ if (isset ($ relayClusterContext [$ contextBoolField ])) {
391
+ $ relayClusterContext [$ contextBoolField ] = filter_var ($ relayClusterContext [$ contextBoolField ], \FILTER_VALIDATE_BOOL );
392
+ }
393
+ }
394
+
395
+ foreach (['max-retries ' , 'serializer ' ,'compression ' ,'compression-level ' ] as $ contextIntField ) {
396
+ if (isset ($ relayClusterContext [$ contextIntField ])) {
397
+ $ relayClusterContext [$ contextIntField ] = filter_var ($ relayClusterContext [$ contextIntField ], \FILTER_VALIDATE_INT );
398
+ }
399
+ }
400
+
380
401
$ relayCluster = new $ class (
381
402
name: null ,
382
403
seeds: $ hosts ,
383
404
connect_timeout: $ params ['timeout ' ],
384
405
command_timeout: $ params ['command_timeout ' ],
385
406
persistent: (bool ) $ params ['persistent ' ],
386
407
auth: $ params ['auth ' ] ?? null ,
387
- context: []
408
+ context: $ relayClusterContext
388
409
);
389
410
} catch (\Relay \Exception $ e ) {
390
411
throw new InvalidArgumentException ('Relay cluster connection failed: ' .$ e ->getMessage ());
@@ -541,11 +562,6 @@ protected function doClear(string $namespace): bool
541
562
$ address = implode (': ' , $ ipAndPort );
542
563
$ cursor = null ;
543
564
do {
544
- // mixed &$iterator
545
- // array|string $key_or_address
546
- // mixed $match = null
547
- // int $count = 0
548
- // string|null $type = null
549
565
$ keys = $ this ->redis ->scan ($ cursor , $ address , $ pattern , 1000 );
550
566
if (isset ($ keys [1 ]) && \is_array ($ keys [1 ])) {
551
567
$ cursor = $ keys [0 ];
0 commit comments