@@ -69,15 +69,6 @@ protected function add($redisAPI, string $key, string $value, int $expire): bool
69
69
*/
70
70
protected function evalScript ($ redis , string $ script , int $ numkeys , array $ arguments )
71
71
{
72
- // Determine if we need to compress eval arguments.
73
- $ lzfCompression = false ;
74
- if (defined ("Redis::COMPRESSION_LZF " ) &&
75
- Redis::COMPRESSION_LZF === $ redis ->getOption (Redis::OPT_COMPRESSION ) &&
76
- function_exists ('lzf_compress ' )
77
- ) {
78
- $ lzfCompression = true ;
79
- }
80
-
81
72
for ($ i = $ numkeys , $ iMax = count ($ arguments ); $ i < $ iMax ; $ i ++) {
82
73
/* If a serializion mode such as "php" or "igbinary" is enabled, the arguments must be
83
74
* serialized by us, because phpredis does not do this for the eval command.
@@ -87,7 +78,7 @@ function_exists('lzf_compress')
87
78
/* If LZF compression is enabled for the redis connection and the runtime has the LZF
88
79
* extension installed, compress the arguments as the final step.
89
80
*/
90
- if ($ lzfCompression ) {
81
+ if ($ this -> hasLzfCompression ( $ redis ) ) {
91
82
$ arguments [$ i ] = lzf_compress ($ arguments [$ i ]);
92
83
}
93
84
}
@@ -98,4 +89,22 @@ function_exists('lzf_compress')
98
89
throw new LockReleaseException ("Failed to release lock " , 0 , $ e );
99
90
}
100
91
}
92
+
93
+ /**
94
+ * Determines if lzf compression is enabled for the given connection.
95
+ *
96
+ * @param \Redis|\RedisCluster $redis Redis connection.
97
+ * @return bool TRUE if lzf comression is enabled, false otherwise.
98
+ */
99
+ private function hasLzfCompression ($ redis ): bool
100
+ {
101
+ if (\defined ('Redis::COMPRESSION_LZF ' ) &&
102
+ Redis::COMPRESSION_LZF === $ redis ->getOption (Redis::OPT_COMPRESSION ) &&
103
+ \function_exists ('lzf_compress ' )
104
+ ) {
105
+ return true ;
106
+ }
107
+
108
+ return false ;
109
+ }
101
110
}
0 commit comments