diff --git a/src/ClientContextInterface.php b/src/ClientContextInterface.php index e29f8bbb..37171fce 100644 --- a/src/ClientContextInterface.php +++ b/src/ClientContextInterface.php @@ -63,6 +63,7 @@ use Predis\Command\CommandInterface; * @method $this cfaddnx(string $key, $item) * @method $this cfcount(string $key, $item) * @method $this cfexists(string $key, $item) + * @method $this cfmexists(string $key, ...$item) * @method $this decr($key) * @method $this decrby($key, $decrement) * @method $this failover(?To $to = null, bool $abort = false, int $timeout = -1) diff --git a/src/ClientInterface.php b/src/ClientInterface.php index f78e56fc..93a7cb78 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -72,6 +72,7 @@ use Predis\Response\Status; * @method int cfaddnx(string $key, $item) * @method int cfcount(string $key, $item) * @method int cfexists(string $key, $item) + * @method int cfmexists(string $key, ...$item) * @method int decr(string $key) * @method int decrby(string $key, int $decrement) * @method Status failover(?To $to = null, bool $abort = false, int $timeout = -1) diff --git a/src/Command/Redis/CuckooFilter/CFMEXISTS.php b/src/Command/Redis/CuckooFilter/CFMEXISTS.php new file mode 100644 index 00000000..61ae9558 --- /dev/null +++ b/src/Command/Redis/CuckooFilter/CFMEXISTS.php @@ -0,0 +1,28 @@ +getCommand(); + $command->setArguments($actualArguments); + + $this->assertSameValues($expectedArguments, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse(): void + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group connected + * @return void + * @requiresRedisBfVersion >= 1.0 + */ + public function testExistsReturnsExistingItemsWithinCuckooFilter(): void + { + $redis = $this->getClient(); + + $this->assertSame([0, 0, 0], $redis->cfmexists('key', 'item1', 'item2', 'item3')); + $redis->cfadd('key', 'item1'); + $this->assertSame([1, 0, 0], $redis->cfmexists('key', 'item1', 'item2', 'item3')); + $redis->cfadd('key', 'item2'); + $redis->cfadd('key', 'item3'); + $this->assertSame([1, 1, 1], $redis->cfmexists('key', 'item1', 'item2', 'item3')); + } +}