Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

BITFIELD_RO

Last updated
BITFIELD_RO key [GET encoding offset ...]
Group
Bitmap
Complexity
O(1) for each GET
Arity
-2 (at least 2 words, counting the command name)
Flags
read-only, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

BITFIELD_RO runs only GET operations of BITFIELD. Because it never writes, it is flagged read-only, so you can send it to read-only replicas and use it where write commands are not allowed. The encodings and offsets are the same as for BITFIELD. A missing key reads as zeros.

Case RESP2 RESP3
Always Array with one integer per GET Array

Errors:

  • ERR BITFIELD_RO only supports the GET subcommand for any other operation.
  • The encoding and offset errors of BITFIELD.
  • WRONGTYPE when the key holds a value that is not a string.
127.0.0.1:6379> BITFIELD counters SET u8 0 255 SET i8 #1 -5
1) (integer) 0
2) (integer) 0
127.0.0.1:6379> BITFIELD_RO counters GET u8 0 GET i8 #1
1) (integer) 255
2) (integer) -5
127.0.0.1:6379> BITFIELD_RO counters INCRBY u8 0 1
(error) ERR BITFIELD_RO only supports the GET subcommand

Same as Redis 7 and Valkey 8.

BITFIELD, GETBIT