@@ -74,6 +74,7 @@ private function create() {
7474 // # TLS support
7575 // # https://github.com/phpredis/phpredis/issues/1600
7676 $ connectionParameters = $ this ->getSslContext ($ config );
77+ $ persistent = $ this ->config ->getValue ('redis.persistent ' , true );
7778
7879 // cluster config
7980 if ($ isCluster ) {
@@ -83,9 +84,9 @@ private function create() {
8384
8485 // Support for older phpredis versions not supporting connectionParameters
8586 if ($ connectionParameters !== null ) {
86- $ this ->instance = new \RedisCluster (null , $ config ['seeds ' ], $ timeout , $ readTimeout , true , $ auth , $ connectionParameters );
87+ $ this ->instance = new \RedisCluster (null , $ config ['seeds ' ], $ timeout , $ readTimeout , $ persistent , $ auth , $ connectionParameters );
8788 } else {
88- $ this ->instance = new \RedisCluster (null , $ config ['seeds ' ], $ timeout , $ readTimeout , true , $ auth );
89+ $ this ->instance = new \RedisCluster (null , $ config ['seeds ' ], $ timeout , $ readTimeout , $ persistent , $ auth );
8990 }
9091
9192 if (isset ($ config ['failover_mode ' ])) {
@@ -104,17 +105,25 @@ private function create() {
104105 $ connectionParameters = [
105106 'stream ' => $ this ->getSslContext ($ config )
106107 ];
107- /**
108- * even though the stubs and documentation don't want you to know this,
109- * pconnect does have the same $connectionParameters argument connect has
110- *
111- * https://github.com/phpredis/phpredis/blob/0264de1824b03fb2d0ad515b4d4ec019cd2dae70/redis.c#L710-L730
112- *
113- * @psalm-suppress TooManyArguments
114- */
115- $ this ->instance ->pconnect ($ host , $ port , $ timeout , null , 0 , $ readTimeout , $ connectionParameters );
108+ if ($ persistent ) {
109+ /**
110+ * even though the stubs and documentation don't want you to know this,
111+ * pconnect does have the same $connectionParameters argument connect has
112+ *
113+ * https://github.com/phpredis/phpredis/blob/0264de1824b03fb2d0ad515b4d4ec019cd2dae70/redis.c#L710-L730
114+ *
115+ * @psalm-suppress TooManyArguments
116+ */
117+ $ this ->instance ->pconnect ($ host , $ port , $ timeout , null , 0 , $ readTimeout , $ connectionParameters );
118+ } else {
119+ $ this ->instance ->connect ($ host , $ port , $ timeout , null , 0 , $ readTimeout , $ connectionParameters );
120+ }
116121 } else {
117- $ this ->instance ->pconnect ($ host , $ port , $ timeout , null , 0 , $ readTimeout );
122+ if ($ persistent ) {
123+ $ this ->instance ->pconnect ($ host , $ port , $ timeout , null , 0 , $ readTimeout );
124+ } else {
125+ $ this ->instance ->connect ($ host , $ port , $ timeout , null , 0 , $ readTimeout );
126+ }
118127 }
119128
120129
0 commit comments