@@ -27,7 +27,7 @@ class PHPRedisMutex extends RedisMutex
27
27
/**
28
28
* Sets the connected Redis APIs.
29
29
*
30
- * The Redis APIs needs to be connected yet . I.e. Redis::connect() was
30
+ * The Redis APIs needs to be connected. I.e. Redis::connect() was
31
31
* called already.
32
32
*
33
33
* @param array<\Redis|\RedisCluster> $redisAPIs The Redis connections.
@@ -43,9 +43,7 @@ public function __construct(array $redisAPIs, string $name, int $timeout = 3)
43
43
}
44
44
45
45
/**
46
- * {@inheritDoc}
47
- *
48
- * @throws \malkusch\lock\exception\LockAcquireException
46
+ * @throws LockAcquireException
49
47
*/
50
48
protected function add ($ redisAPI , string $ key , string $ value , int $ expire ): bool
51
49
{
@@ -63,19 +61,22 @@ protected function add($redisAPI, string $key, string $value, int $expire): bool
63
61
}
64
62
65
63
/**
66
- * {@inheritDoc}
67
- *
68
64
* @param \Redis|\RedisCluster $redis The Redis or RedisCluster connection.
65
+ * @throws LockReleaseException
69
66
*/
70
67
protected function evalScript ($ redis , string $ script , int $ numkeys , array $ arguments )
71
68
{
72
- for ($ i = $ numkeys , $ iMax = count ($ arguments ); $ i < $ iMax ; $ i ++) {
73
- /* If a serializion mode such as "php" or "igbinary" is enabled, the arguments must be
69
+ for ($ i = $ numkeys ; $ i < \count ($ arguments ); $ i ++) {
70
+ /*
71
+ * If a serialization mode such as "php" or "igbinary" is enabled, the arguments must be
74
72
* serialized by us, because phpredis does not do this for the eval command.
73
+ *
74
+ * The keys must not be serialized.
75
75
*/
76
76
$ arguments [$ i ] = $ redis ->_serialize ($ arguments [$ i ]);
77
77
78
- /* If LZF compression is enabled for the redis connection and the runtime has the LZF
78
+ /*
79
+ * If LZF compression is enabled for the redis connection and the runtime has the LZF
79
80
* extension installed, compress the arguments as the final step.
80
81
*/
81
82
if ($ this ->hasLzfCompression ($ redis )) {
@@ -94,17 +95,14 @@ protected function evalScript($redis, string $script, int $numkeys, array $argum
94
95
* Determines if lzf compression is enabled for the given connection.
95
96
*
96
97
* @param \Redis|\RedisCluster $redis Redis connection.
97
- * @return bool TRUE if lzf comression is enabled, false otherwise.
98
+ * @return bool TRUE if lzf compression is enabled, false otherwise.
98
99
*/
99
100
private function hasLzfCompression ($ redis ): bool
100
101
{
101
- if (\defined ('Redis::COMPRESSION_LZF ' ) &&
102
- Redis::COMPRESSION_LZF === $ redis ->getOption (Redis::OPT_COMPRESSION ) &&
103
- \function_exists ('lzf_compress ' )
104
- ) {
105
- return true ;
102
+ if (!\defined ('Redis::COMPRESSION_LZF ' )) {
103
+ return false ;
106
104
}
107
105
108
- return false ;
106
+ return Redis:: COMPRESSION_LZF === $ redis -> getOption (Redis:: OPT_COMPRESSION ) ;
109
107
}
110
108
}
0 commit comments