From 16bdd83d23b84a2182e129c63b1683a02c076556 Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Sat, 26 Aug 2023 00:27:24 +0300 Subject: [PATCH] Added EXPIRETIME command to KeyPrefixProcessor (#1369) * Added EXPIRETIME command to KeyPrefixProcessor * Fixed test responses for Redis 7.2 * Marked test as relay-incompatible --- src/Command/Processor/KeyPrefixProcessor.php | 3 +++ tests/Predis/ClientTest.php | 1 + .../Command/Processor/KeyPrefixProcessorTest.php | 5 +++++ tests/Predis/Command/Redis/ACL_Test.php | 2 +- tests/Predis/Command/Redis/OBJECT_Test.php | 15 ++++++++++++++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Command/Processor/KeyPrefixProcessor.php b/src/Command/Processor/KeyPrefixProcessor.php index 05595ac1..d7a30c88 100644 --- a/src/Command/Processor/KeyPrefixProcessor.php +++ b/src/Command/Processor/KeyPrefixProcessor.php @@ -190,6 +190,9 @@ class KeyPrefixProcessor implements ProcessorInterface /* ---------------- Redis 6.2 ---------------- */ 'GETDEL' => $prefixFirst, + /* ---------------- Redis 7.0 ---------------- */ + 'EXPIRETIME' => $prefixFirst, + /* RedisJSON */ 'JSON.ARRAPPEND' => $prefixFirst, 'JSON.ARRINDEX' => $prefixFirst, diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index fba37d98..01905834 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -1255,6 +1255,7 @@ class ClientTest extends PredisTestCase /** * @group connected + * @group relay-incompatible * @requiresRedisVersion >= 7.2.0 */ public function testSetClientInfoOnConnection(): void diff --git a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php index b8acc4e1..1cadb544 100644 --- a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php +++ b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php @@ -978,6 +978,11 @@ class KeyPrefixProcessorTest extends PredisTestCase ['key'], ['prefix:key'], ], + /* ---------------- Redis 7.0 ---------------- */ + ['EXPIRETIME', + ['key'], + ['prefix:key'], + ], ]; } } diff --git a/tests/Predis/Command/Redis/ACL_Test.php b/tests/Predis/Command/Redis/ACL_Test.php index ff3d5fc6..3f270b5e 100644 --- a/tests/Predis/Command/Redis/ACL_Test.php +++ b/tests/Predis/Command/Redis/ACL_Test.php @@ -101,7 +101,7 @@ class ACL_Test extends PredisCommandTestCase $redis->acl->dryRun('Test', 'SET', 'foo', 'bar') ); $this->assertEquals( - "This user has no permissions to run the 'get' command", + "User Test has no permissions to run the 'get' command", $redis->acl->dryRun('Test', 'GET', 'foo') ); } diff --git a/tests/Predis/Command/Redis/OBJECT_Test.php b/tests/Predis/Command/Redis/OBJECT_Test.php index 7fbec0e6..51e93ea5 100644 --- a/tests/Predis/Command/Redis/OBJECT_Test.php +++ b/tests/Predis/Command/Redis/OBJECT_Test.php @@ -82,7 +82,7 @@ class OBJECT_Test extends PredisCommandTestCase /** * @group connected - * @requiresRedisVersion >= 2.2.3 + * @requiresRedisVersion < 7.2.0 */ public function testObjectEncoding(): void { @@ -92,6 +92,19 @@ class OBJECT_Test extends PredisCommandTestCase $this->assertMatchesRegularExpression('/[zip|quick]list/', $redis->object('ENCODING', 'list:metavars')); } + /** + * @group connected + * @requiresRedisVersion >= 7.2.0 + */ + public function testObjectEncodingReturnsUpdatedResponse(): void + { + $redis = $this->getClient(); + + $redis->lpush('list:metavars', 'foo', 'bar'); + + $this->assertSame('listpack', $redis->object('ENCODING', 'list:metavars')); + } + /** * @group connected * @requiresRedisVersion >= 2.2.3