From 98d4f802636e99de2e70e3252ea76dfde395cd65 Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Thu, 30 Mar 2023 00:03:45 +1000 Subject: [PATCH] Add missing stream key prefixes (#1230) * Added missing stream key prefixes * Tested stream command key prefixing --- src/Command/Processor/KeyPrefixProcessor.php | 2 ++ .../Processor/KeyPrefixProcessorTest.php | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/Command/Processor/KeyPrefixProcessor.php b/src/Command/Processor/KeyPrefixProcessor.php index 6542b5c0..8de9a847 100644 --- a/src/Command/Processor/KeyPrefixProcessor.php +++ b/src/Command/Processor/KeyPrefixProcessor.php @@ -181,9 +181,11 @@ class KeyPrefixProcessor implements ProcessorInterface /* ---------------- Redis 5.0 ---------------- */ 'XADD' => $prefixFirst, 'XRANGE' => $prefixFirst, + 'XREVRANGE' => $prefixFirst, 'XDEL' => $prefixFirst, 'XLEN' => $prefixFirst, 'XACK' => $prefixFirst, + 'XTRIM' => $prefixFirst, ]; } diff --git a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php index 6a246ec2..205f2af5 100644 --- a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php +++ b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php @@ -944,6 +944,35 @@ class KeyPrefixProcessorTest extends PredisTestCase ['key', 'member', '100', 'km', 'WITHDIST', 'STORE', 'key:store', 'STOREDIST', 'key:storedist'], ['prefix:key', 'member', '100', 'km', 'WITHDIST', 'STORE', 'prefix:key:store', 'STOREDIST', 'prefix:key:storedist'], ], + /* ---------------- Redis 5.0 ---------------- */ + ['XADD', + ['key', '*', ['field' => 'value']], + ['prefix:key', '*', ['field' => 'value']], + ], + ['XRANGE', + ['key', '-', '+'], + ['prefix:key', '-', '+'], + ], + ['XREVRANGE', + ['key', '+', '-'], + ['prefix:key', '+', '-'], + ], + ['XDEL', + ['key', 'id'], + ['prefix:key', 'id'], + ], + ['XLEN', + ['key'], + ['prefix:key'], + ], + ['XACK', + ['key', 'group', 'id'], + ['prefix:key', 'group', 'id'], + ], + ['XTRIM', + ['key', 'MAXLEN', 100], + ['prefix:key', 'MAXLEN', 100], + ], ]; } }