From 48514b6cb3e98af073c85a214c2767aff16e7741 Mon Sep 17 00:00:00 2001 From: dvora-h Date: Tue, 26 Apr 2022 16:04:54 +0300 Subject: [PATCH] Add support for COMMAND GETKEYSANDFLAGS --- redis/commands/core.py | 8 ++++++++ tests/test_commands.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/redis/commands/core.py b/redis/commands/core.py index 606256a33c..4784578d68 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -743,6 +743,14 @@ def command_info(self, **kwargs) -> None: def command_count(self, **kwargs) -> ResponseT: return self.execute_command("COMMAND COUNT", **kwargs) + def command_getkeysandflags(self, *args: List[str]) -> List[Union[str, List[str]]]: + """ + Returns array of keys from a full Redis command and their usage flags. + + For more information see https://redis.io/commands/command-getkeysandflags + """ + return self.execute_command("COMMAND GETKEYSANDFLAGS", *args) + def command_docs(self, *args): """ This function throws a NotImplementedError since it is intentionally diff --git a/tests/test_commands.py b/tests/test_commands.py index de94539b82..f83bb7996d 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -4468,6 +4468,15 @@ def test_command(self, r): assert "set" in cmds assert "get" in cmds + @pytest.mark.onlynoncluster + @skip_if_server_version_lt("7.0.0") + @skip_if_redis_enterprise() + def test_command_getkeysandflags(self, r: redis.Redis): + res = [["mylist1", ["RW", "access", "delete"]], ["mylist2", ["RW", "insert"]]] + assert res == r.command_getkeysandflags( + "LMOVE", "mylist1", "mylist2", "left", "left" + ) + @pytest.mark.onlynoncluster @skip_if_server_version_lt("4.0.0") @skip_if_redis_enterprise()