From 031b2087b57713d29b98140fb1f0b9f7b4fc7a21 Mon Sep 17 00:00:00 2001 From: Alibi Date: Sun, 21 Aug 2022 15:18:02 +0600 Subject: Add BITFIELD_RO (#2340) --- redis/commands/core.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'redis/commands/core.py') diff --git a/redis/commands/core.py b/redis/commands/core.py index 6cf0457..51f30d2 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -1504,6 +1504,29 @@ class BasicKeyCommands(CommandsProtocol): """ return BitFieldOperation(self, key, default_overflow=default_overflow) + def bitfield_ro( + self: Union["Redis", "AsyncRedis"], + key: KeyT, + encoding: str, + offset: BitfieldOffsetT, + items: Optional[list] = None, + ) -> ResponseT: + """ + Return an array of the specified bitfield values + where the first value is found using ``encoding`` and ``offset`` + parameters and remaining values are result of corresponding + encoding/offset pairs in optional list ``items`` + Read-only variant of the BITFIELD command. + + For more information see https://redis.io/commands/bitfield_ro + """ + params = [key, "GET", encoding, offset] + + items = items or [] + for encoding, offset in items: + params.extend(["GET", encoding, offset]) + return self.execute_command("BITFIELD_RO", *params) + def bitop(self, operation: str, dest: KeyT, *keys: KeyT) -> ResponseT: """ Perform a bitwise operation using ``operation`` between ``keys`` and -- cgit v1.2.1