diff --git a/CHANGELOG.md b/CHANGELOG.md index 38292984..18164aa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ ## Changelog +## Unreleased + +### Added +- Make ZMSCORE command Prefixable and add to a ClusterStrategy (#1692) ## v3.5.1 (2026-06-11) ### Added diff --git a/src/Client.php b/src/Client.php index ff5ebe8c..4590dd3f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -272,7 +272,7 @@ class Client implements ClientInterface, IteratorAggregate /** * Applies the configured serializer and compression to given value. * - * @param mixed $value + * @param mixed $value * @return mixed */ public function pack($value) @@ -285,7 +285,7 @@ class Client implements ClientInterface, IteratorAggregate /** * Deserializes and decompresses to given value. * - * @param mixed $value + * @param mixed $value * @return mixed */ public function unpack($value) diff --git a/src/Cluster/ClusterStrategy.php b/src/Cluster/ClusterStrategy.php index 16064b06..2a352e2b 100644 --- a/src/Cluster/ClusterStrategy.php +++ b/src/Cluster/ClusterStrategy.php @@ -153,6 +153,7 @@ abstract class ClusterStrategy implements StrategyInterface 'ZREVRANGEBYSCORE' => $getKeyFromFirstArgument, 'ZREVRANK' => $getKeyFromFirstArgument, 'ZSCORE' => $getKeyFromFirstArgument, + 'ZMSCORE' => $getKeyFromFirstArgument, 'ZUNIONSTORE' => [$this, 'getKeyFromZsetAggregationCommands'], 'ZSCAN' => $getKeyFromFirstArgument, 'ZLEXCOUNT' => $getKeyFromFirstArgument, diff --git a/src/Command/Redis/ZMSCORE.php b/src/Command/Redis/ZMSCORE.php index 79715c53..92d2edd6 100644 --- a/src/Command/Redis/ZMSCORE.php +++ b/src/Command/Redis/ZMSCORE.php @@ -12,7 +12,7 @@ namespace Predis\Command\Redis; -use Predis\Command\Command as RedisCommand; +use Predis\Command\PrefixableCommand as RedisCommand; /** * @see https://redis.io/commands/zmscore/ @@ -31,4 +31,9 @@ class ZMSCORE extends RedisCommand { return 'ZMSCORE'; } + + public function prefixKeys($prefix) + { + $this->applyPrefixForFirstArgument($prefix); + } } diff --git a/tests/Predis/Cluster/PredisStrategyTest.php b/tests/Predis/Cluster/PredisStrategyTest.php index 1679f210..96c7aa52 100644 --- a/tests/Predis/Cluster/PredisStrategyTest.php +++ b/tests/Predis/Cluster/PredisStrategyTest.php @@ -480,6 +480,7 @@ class PredisStrategyTest extends PredisTestCase 'ZREVRANGEBYSCORE' => 'keys-first', 'ZREVRANK' => 'keys-first', 'ZSCORE' => 'keys-first', + 'ZMSCORE' => 'keys-first', 'ZUNIONSTORE' => 'keys-zaggregated', 'ZSCAN' => 'keys-first', 'ZLEXCOUNT' => 'keys-first', diff --git a/tests/Predis/Cluster/RedisStrategyTest.php b/tests/Predis/Cluster/RedisStrategyTest.php index d23b53c3..3b88c056 100644 --- a/tests/Predis/Cluster/RedisStrategyTest.php +++ b/tests/Predis/Cluster/RedisStrategyTest.php @@ -503,6 +503,7 @@ class RedisStrategyTest extends PredisTestCase 'ZREVRANGEBYSCORE' => 'keys-first', 'ZREVRANK' => 'keys-first', 'ZSCORE' => 'keys-first', + 'ZMSCORE' => 'keys-first', 'ZUNIONSTORE' => 'keys-zaggregated', 'ZSCAN' => 'keys-first', 'ZLEXCOUNT' => 'keys-first', diff --git a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php index 41f8c513..0b097d0f 100644 --- a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php +++ b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php @@ -485,6 +485,10 @@ class KeyPrefixProcessorTest extends PredisTestCase ['key', 'member'], ['prefix:key', 'member'], ], + ['ZMSCORE', + ['key', 'member1', 'member2'], + ['prefix:key', 'member1', 'member2'], + ], ['ZREMRANGEBYSCORE', ['key', 0, 10], ['prefix:key', 0, 10], diff --git a/tests/Predis/Command/Redis/UNLINK_Test.php b/tests/Predis/Command/Redis/UNLINK_Test.php index 593ff139..86f5d57b 100644 --- a/tests/Predis/Command/Redis/UNLINK_Test.php +++ b/tests/Predis/Command/Redis/UNLINK_Test.php @@ -76,7 +76,7 @@ class UNLINK_Test extends PredisCommandTestCase */ public function testPrefixKeys(): void { - /** @var \Predis\Command\Redis\UNLINK $command */ + /** @var UNLINK $command */ $command = $this->getCommand(); $inputArguments = ['arg1', 'arg2', 'arg3', 'arg4']; $prefix = 'prefix:'; diff --git a/tests/Predis/Command/Redis/ZMSCORE_Test.php b/tests/Predis/Command/Redis/ZMSCORE_Test.php index 7f631044..19be8ee2 100644 --- a/tests/Predis/Command/Redis/ZMSCORE_Test.php +++ b/tests/Predis/Command/Redis/ZMSCORE_Test.php @@ -12,6 +12,7 @@ namespace Predis\Command\Redis; +use Predis\Command\PrefixableCommand; use Predis\Response\ServerException; /** @@ -58,6 +59,23 @@ class ZMSCORE_Test extends PredisCommandTestCase $this->assertSame(1, $this->getCommand()->parseResponse(1)); } + /** + * @group disconnected + */ + public function testPrefixKeys(): void + { + /** @var PrefixableCommand $command */ + $command = $this->getCommand(); + $actualArguments = ['arg1', 'arg2', 'arg3', 'arg4']; + $prefix = 'prefix:'; + $expectedArguments = ['prefix:arg1', 'arg2', 'arg3', 'arg4']; + + $command->setArguments($actualArguments); + $command->prefixKeys($prefix); + + $this->assertSame($expectedArguments, $command->getArguments()); + } + /** * @group connected * @dataProvider membersProvider