diff --git a/src/ClientContextInterface.php b/src/ClientContextInterface.php index 602a9087..868501f9 100644 --- a/src/ClientContextInterface.php +++ b/src/ClientContextInterface.php @@ -48,6 +48,7 @@ use Predis\Command\CommandInterface; * @method $this bfmadd(string $key, ...$item) * @method $this bfmexists(string $key, ...$item) * @method $this bfreserve(string $key, float $errorRate, int $capacity, int $expansion = -1, bool $nonScaling = false) + * @method $this bfscandump(string $key, int $iterator) * @method $this bitcount($key, $start = null, $end = null) * @method $this bitop($operation, $destkey, $key) * @method $this bitfield($key, $subcommand, ...$subcommandArg) diff --git a/src/ClientInterface.php b/src/ClientInterface.php index af00d98d..10b56037 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -57,6 +57,7 @@ use Predis\Response\Status; * @method array bfmadd(string $key, ...$item) * @method array bfmexists(string $key, ...$item) * @method Status bfreserve(string $key, float $errorRate, int $capacity, int $expansion = -1, bool $nonScaling = false) + * @method array bfscandump(string $key, int $iterator) * @method int bitcount(string $key, $start = null, $end = null) * @method int bitop($operation, $destkey, $key) * @method array|null bitfield(string $key, $subcommand, ...$subcommandArg) diff --git a/src/Command/Redis/BloomFilter/BFSCANDUMP.php b/src/Command/Redis/BloomFilter/BFSCANDUMP.php new file mode 100644 index 00000000..f8576d2d --- /dev/null +++ b/src/Command/Redis/BloomFilter/BFSCANDUMP.php @@ -0,0 +1,29 @@ +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.0 + */ + public function testScanDumpReturnsCorrectDataChunk(): void + { + $expectedIterator = 1; + $redis = $this->getClient(); + + $redis->bfadd('key', 'item1'); + [$iterator, $dataChunk] = $redis->bfscandump('key', 0); + + $this->assertSame($expectedIterator, $iterator); + $this->assertNotEmpty($dataChunk); + } + + /** + * @group connected + * @requiresRedisBfVersion >= 1.0.0 + */ + public function testThrowsExceptionOnWrongType(): void + { + $this->expectException(ServerException::class); + $this->expectExceptionMessage('Operation against a key holding the wrong kind of value'); + + $redis = $this->getClient(); + + $redis->set('bfscandump_foo', 'bar'); + $redis->bfscandump('bfscandump_foo', 0); + } +}