diff --git a/CHANGELOG.md b/CHANGELOG.md index c7bef6ab..204a8d34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Added support for `LMOVEM` and `BLMOVEM` commands - Added support for `FT.ALIASLIST` command - Added stream commands to ClusterStrategy +- Added vector sets commands to ClusterStrategy ### Fixed - Fixed Sentinel does not wipe servers on exception caused (#1694) diff --git a/src/Cluster/ClusterStrategy.php b/src/Cluster/ClusterStrategy.php index 04f20c84..d73a620a 100644 --- a/src/Cluster/ClusterStrategy.php +++ b/src/Cluster/ClusterStrategy.php @@ -201,6 +201,20 @@ abstract class ClusterStrategy implements StrategyInterface 'XSETID' => $getKeyFromFirstArgument, 'XTRIM' => $getKeyFromFirstArgument, + /* commands operating on vector sets */ + 'VADD' => $getKeyFromFirstArgument, + 'VCARD' => $getKeyFromFirstArgument, + 'VDIM' => $getKeyFromFirstArgument, + 'VEMB' => $getKeyFromFirstArgument, + 'VGETATTR' => $getKeyFromFirstArgument, + 'VINFO' => $getKeyFromFirstArgument, + 'VLINKS' => $getKeyFromFirstArgument, + 'VRANDMEMBER' => $getKeyFromFirstArgument, + 'VRANGE' => $getKeyFromFirstArgument, + 'VREM' => $getKeyFromFirstArgument, + 'VSETATTR' => $getKeyFromFirstArgument, + 'VSIM' => $getKeyFromFirstArgument, + /* commands operating on time series */ 'TS.READ' => $getKeyFromFirstArgument, diff --git a/tests/Predis/Cluster/PredisStrategyTest.php b/tests/Predis/Cluster/PredisStrategyTest.php index 92c82af4..c874202e 100644 --- a/tests/Predis/Cluster/PredisStrategyTest.php +++ b/tests/Predis/Cluster/PredisStrategyTest.php @@ -331,6 +331,25 @@ class PredisStrategyTest extends PredisTestCase } } + /** + * @group disconnected + */ + public function testKeysForVectorSetCommands(): void + { + $strategy = $this->getClusterStrategy(); + $commands = $this->getCommandFactory(); + + $arguments = [ + 'VADD' => ['key', [1.0, 2.0], 'element'], + 'VSIM' => ['key', [1.0, 2.0]], + ]; + + foreach ($this->getExpectedCommands('keys-vector') as $commandID) { + $command = $commands->create($commandID, $arguments[$commandID]); + $this->assertSame($strategy->getSlotByKey('key'), $strategy->getSlot($command), $commandID); + } + } + /** * @group disconnected */ @@ -667,6 +686,20 @@ class PredisStrategyTest extends PredisTestCase 'XSETID' => 'keys-first', 'XTRIM' => 'keys-first', + /* commands operating on vector sets */ + 'VADD' => 'keys-vector', + 'VCARD' => 'keys-first', + 'VDIM' => 'keys-first', + 'VEMB' => 'keys-first', + 'VGETATTR' => 'keys-first', + 'VINFO' => 'keys-first', + 'VLINKS' => 'keys-first', + 'VRANDMEMBER' => 'keys-first', + 'VRANGE' => 'keys-first', + 'VREM' => 'keys-first', + 'VSETATTR' => 'keys-first', + 'VSIM' => 'keys-vector', + /* commands operating on time series */ 'TS.READ' => 'keys-first', diff --git a/tests/Predis/Cluster/RedisStrategyTest.php b/tests/Predis/Cluster/RedisStrategyTest.php index db7367a0..3601aa59 100644 --- a/tests/Predis/Cluster/RedisStrategyTest.php +++ b/tests/Predis/Cluster/RedisStrategyTest.php @@ -341,6 +341,25 @@ class RedisStrategyTest extends PredisTestCase } } + /** + * @group disconnected + */ + public function testKeysForVectorSetCommands(): void + { + $strategy = $this->getClusterStrategy(); + $commands = $this->getCommandFactory(); + + $arguments = [ + 'VADD' => ['key', [1.0, 2.0], 'element'], + 'VSIM' => ['key', [1.0, 2.0]], + ]; + + foreach ($this->getExpectedCommands('keys-vector') as $commandID) { + $command = $commands->create($commandID, $arguments[$commandID]); + $this->assertSame($strategy->getSlotByKey('key'), $strategy->getSlot($command), $commandID); + } + } + /** * @group disconnected */ @@ -687,6 +706,20 @@ class RedisStrategyTest extends PredisTestCase 'XSETID' => 'keys-first', 'XTRIM' => 'keys-first', + /* commands operating on vector sets */ + 'VADD' => 'keys-vector', + 'VCARD' => 'keys-first', + 'VDIM' => 'keys-first', + 'VEMB' => 'keys-first', + 'VGETATTR' => 'keys-first', + 'VINFO' => 'keys-first', + 'VLINKS' => 'keys-first', + 'VRANDMEMBER' => 'keys-first', + 'VRANGE' => 'keys-first', + 'VREM' => 'keys-first', + 'VSETATTR' => 'keys-first', + 'VSIM' => 'keys-vector', + /* commands operating on time series */ 'TS.READ' => 'keys-first',