diff --git a/src/ClientContextInterface.php b/src/ClientContextInterface.php index 48c53926..57475991 100644 --- a/src/ClientContextInterface.php +++ b/src/ClientContextInterface.php @@ -48,6 +48,7 @@ use Predis\Command\CommandInterface; * @method $this get($key) * @method $this getbit($key, $offset) * @method $this getrange($key, $start, $end) + * @method $this getdel(string $key) * @method $this getset($key, $value) * @method $this incr($key) * @method $this incrby($key, $increment) diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 5ec9ed03..a223b550 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -57,6 +57,7 @@ use Predis\Response\Status; * @method string|null get(string $key) * @method int getbit(string $key, $offset) * @method string getrange(string $key, $start, $end) + * @method string getdel(string $key) * @method string|null getset(string $key, $value) * @method int incr(string $key) * @method int incrby(string $key, int $increment) diff --git a/src/Command/Redis/GETDEL.php b/src/Command/Redis/GETDEL.php new file mode 100644 index 00000000..f860f08c --- /dev/null +++ b/src/Command/Redis/GETDEL.php @@ -0,0 +1,13 @@ +getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse(): void + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group connected + * @return void + * @requiresRedisVersion >= 6.2.0 + */ + public function testReturnsValueForGivenKeyAndDeleteIt(): void + { + $redis = $this->getClient(); + $expectedKey = 'key'; + $expectedValue = 'value'; + + $redis->set($expectedKey, $expectedValue); + + $actualResponse = $redis->getdel($expectedKey); + + $this->assertSame($expectedValue, $actualResponse); + $this->assertNull($redis->get($expectedKey)); + } +}