Skip to content

Commit

Permalink
Add support for COMMAND GETKEYSANDFLAGS (#2141)
Browse files Browse the repository at this point in the history
Co-authored-by: Chayim <chayim@users.noreply.github.com>
  • Loading branch information
dvora-h and chayim authored Apr 27, 2022
1 parent 6832705 commit 2da2ac3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2da2ac3

Please sign in to comment.