Skip to content

Commit 2da2ac3

Browse files
dvora-hchayim
andauthored
Add support for COMMAND GETKEYSANDFLAGS (#2141)
Co-authored-by: Chayim <[email protected]>
1 parent 6832705 commit 2da2ac3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

redis/commands/core.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,14 @@ def command_info(self, **kwargs) -> None:
743743
def command_count(self, **kwargs) -> ResponseT:
744744
return self.execute_command("COMMAND COUNT", **kwargs)
745745

746+
def command_getkeysandflags(self, *args: List[str]) -> List[Union[str, List[str]]]:
747+
"""
748+
Returns array of keys from a full Redis command and their usage flags.
749+
750+
For more information see https://redis.io/commands/command-getkeysandflags
751+
"""
752+
return self.execute_command("COMMAND GETKEYSANDFLAGS", *args)
753+
746754
def command_docs(self, *args):
747755
"""
748756
This function throws a NotImplementedError since it is intentionally

tests/test_commands.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4468,6 +4468,15 @@ def test_command(self, r):
44684468
assert "set" in cmds
44694469
assert "get" in cmds
44704470

4471+
@pytest.mark.onlynoncluster
4472+
@skip_if_server_version_lt("7.0.0")
4473+
@skip_if_redis_enterprise()
4474+
def test_command_getkeysandflags(self, r: redis.Redis):
4475+
res = [["mylist1", ["RW", "access", "delete"]], ["mylist2", ["RW", "insert"]]]
4476+
assert res == r.command_getkeysandflags(
4477+
"LMOVE", "mylist1", "mylist2", "left", "left"
4478+
)
4479+
44714480
@pytest.mark.onlynoncluster
44724481
@skip_if_server_version_lt("4.0.0")
44734482
@skip_if_redis_enterprise()

0 commit comments

Comments
 (0)