# BITFIELD_RO

> Read integer fields inside a string; the read-only form of BITFIELD.

URL: https://docs.hotkv.com/commands/bitfield_ro/

```
BITFIELD_RO key [GET encoding offset ...]
```

- Group: Bitmap
- Complexity: O(1) for each GET
- HotKV Cloud: all plans
- On-Premise: no license needed

`BITFIELD_RO` runs only `GET` operations of [BITFIELD](https://docs.hotkv.com/commands/bitfield/index.md).
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.

## Return value

| 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](https://docs.hotkv.com/commands/bitfield/index.md).
- `WRONGTYPE` when the key holds a value that is not a string.

## Examples

```
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
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[BITFIELD](https://docs.hotkv.com/commands/bitfield/index.md), [GETBIT](https://docs.hotkv.com/commands/getbit/index.md)