@@ -51,13 +51,13 @@ protected function getSerializers() {
51
51
}
52
52
53
53
protected function getCompressors () {
54
- $ result [] = Redis::COMPRESSION_NONE ;
54
+ $ result [' none ' ] = Redis::COMPRESSION_NONE ;
55
55
if (defined ('Redis::COMPRESSION_LZF ' ))
56
- $ result [] = Redis::COMPRESSION_LZF ;
56
+ $ result [' lzf ' ] = Redis::COMPRESSION_LZF ;
57
57
if (defined ('Redis::COMPRESSION_LZ4 ' ))
58
- $ result [] = Redis::COMPRESSION_LZ4 ;
58
+ $ result [' lz4 ' ] = Redis::COMPRESSION_LZ4 ;
59
59
if (defined ('Redis::COMPRESSION_ZSTD ' ))
60
- $ result [] = Redis::COMPRESSION_ZSTD ;
60
+ $ result [' zstd ' ] = Redis::COMPRESSION_ZSTD ;
61
61
62
62
return $ result ;
63
63
}
@@ -7377,6 +7377,26 @@ public function testHighPorts() {
7377
7377
}
7378
7378
}
7379
7379
7380
+ public function testSession_compression () {
7381
+ $ this ->setSessionHandler ();
7382
+
7383
+ foreach ($ this ->getCompressors () as $ name => $ val ) {
7384
+
7385
+ $ id = $ this ->generateSessionId ();
7386
+ $ res = $ this ->startSessionProcess ($ id , 0 , false , 300 , true , null ,
7387
+ -1 , 0 , "testing_compression_ $ name " , 1440 ,
7388
+ $ name );
7389
+
7390
+ $ this ->assertTrue ($ res );
7391
+
7392
+ $ key = $ this ->sessionPrefix . $ id ;
7393
+
7394
+ $ this ->redis ->setOption (Redis::OPT_COMPRESSION , $ val );
7395
+ $ this ->assertTrue ($ this ->redis ->get ($ key ) !== false );
7396
+ $ this ->redis ->setOption (Redis::OPT_COMPRESSION , Redis::COMPRESSION_NONE );
7397
+ }
7398
+ }
7399
+
7380
7400
public function testSession_savedToRedis ()
7381
7401
{
7382
7402
$ this ->setSessionHandler ();
@@ -7878,33 +7898,40 @@ private function generateSessionId()
7878
7898
* @param int $lock_retries
7879
7899
* @param int $lock_expires
7880
7900
* @param string $sessionData
7881
- *
7882
7901
* @param int $sessionLifetime
7902
+ * @param string $sessionCompression
7883
7903
*
7884
7904
* @return bool
7885
7905
* @throws Exception
7886
7906
*/
7887
- private function startSessionProcess ($ sessionId , $ sleepTime , $ background , $ maxExecutionTime = 300 , $ locking_enabled = true , $ lock_wait_time = null , $ lock_retries = -1 , $ lock_expires = 0 , $ sessionData = '' , $ sessionLifetime = 1440 )
7907
+ private function startSessionProcess ($ sessionId , $ sleepTime , $ background ,
7908
+ $ maxExecutionTime = 300 ,
7909
+ $ locking_enabled = true ,
7910
+ $ lock_wait_time = null ,
7911
+ $ lock_retries = -1 ,
7912
+ $ lock_expires = 0 ,
7913
+ $ sessionData = '' ,
7914
+ $ sessionLifetime = 1440 ,
7915
+ $ sessionCompression = 'none ' )
7888
7916
{
7889
- if (substr (php_uname (), 0 , 7 ) == " Windows " ){
7917
+ if (strpos (php_uname (), ' Windows ' ) ! == false )
7890
7918
$ this ->markTestSkipped ();
7891
- return true ;
7892
- } else {
7893
- $ commandParameters = [$ this ->getFullHostPath (), $ this ->sessionSaveHandler , $ sessionId , $ sleepTime , $ maxExecutionTime , $ lock_retries , $ lock_expires , $ sessionData , $ sessionLifetime ];
7894
- if ($ locking_enabled ) {
7895
- $ commandParameters [] = '1 ' ;
7896
7919
7897
- if ($ lock_wait_time != null ) {
7898
- $ commandParameters [] = $ lock_wait_time ;
7899
- }
7900
- }
7901
- $ commandParameters = array_map ('escapeshellarg ' , $ commandParameters );
7920
+ $ commandParameters = [
7921
+ $ this ->getFullHostPath (), $ this ->sessionSaveHandler , $ sessionId ,
7922
+ $ sleepTime , $ maxExecutionTime , $ lock_retries , $ lock_expires ,
7923
+ $ sessionData , $ sessionLifetime , $ locking_enabled ? 1 : 0 ,
7924
+ $ lock_wait_time ?? 0 , $ sessionCompression
7925
+ ];
7902
7926
7903
- $ command = self ::getPhpCommand ('startSession.php ' ) . implode (' ' , $ commandParameters );
7904
- $ command .= $ background ? ' 2>/dev/null > /dev/null & ' : ' 2>&1 ' ;
7905
- exec ($ command , $ output );
7906
- return ($ background || (count ($ output ) == 1 && $ output [0 ] == 'SUCCESS ' )) ? true : false ;
7907
- }
7927
+ $ commandParameters = array_map ('escapeshellarg ' , $ commandParameters );
7928
+ $ commandParameters [] = $ background ? '>/dev/null 2>&1 & ' : '2>&1 ' ;
7929
+
7930
+ $ command = self ::getPhpCommand ('startSession.php ' ) . implode (' ' , $ commandParameters );
7931
+
7932
+ exec ($ command , $ output );
7933
+
7934
+ return ($ background || (count ($ output ) == 1 && $ output [0 ] == 'SUCCESS ' ));
7908
7935
}
7909
7936
7910
7937
/**
0 commit comments