From bf528fc7f776ce8e926b2e9abfa4e2460d73baa4 Mon Sep 17 00:00:00 2001 From: shacharPash <93581407+shacharPash@users.noreply.github.com> Date: Sun, 30 Apr 2023 14:57:27 +0300 Subject: Add WITHSCORES to ZREVRANK Command (#2725) * add withscores to zrevrank * change 0 -> 2 * fix errors * split test --- redis/commands/core.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'redis/commands/core.py') diff --git a/redis/commands/core.py b/redis/commands/core.py index e2cabb8..d67291b 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -4693,13 +4693,22 @@ class SortedSetCommands(CommandsProtocol): """ return self.execute_command("ZREMRANGEBYSCORE", name, min, max) - def zrevrank(self, name: KeyT, value: EncodableT) -> ResponseT: + def zrevrank( + self, + name: KeyT, + value: EncodableT, + withscore: bool = False, + ) -> ResponseT: """ Returns a 0-based value indicating the descending rank of - ``value`` in sorted set ``name`` + ``value`` in sorted set ``name``. + The optional ``withscore`` argument supplements the command's + reply with the score of the element returned. For more information see https://redis.io/commands/zrevrank """ + if withscore: + return self.execute_command("ZREVRANK", name, value, "WITHSCORE") return self.execute_command("ZREVRANK", name, value) def zscore(self, name: KeyT, value: EncodableT) -> ResponseT: -- cgit v1.2.1