Back to Redis

BITFIELD_RO

content/commands/bitfield_ro.md

latest1.8 KB
Original Source

Read-only variant of the [BITFIELD]({{< relref "/commands/bitfield" >}}) command. It is like the original [BITFIELD]({{< relref "/commands/bitfield" >}}) but only accepts GET subcommand and can safely be used in read-only replicas.

Since the original [BITFIELD]({{< relref "/commands/bitfield" >}}) has SET and INCRBY options it is technically flagged as a writing command in the Redis command table. For this reason read-only replicas in a Redis Cluster will redirect it to the master instance even if the connection is in read-only mode (see the [READONLY]({{< relref "/commands/readonly" >}}) command of Redis Cluster).

Since Redis 6.2, the BITFIELD_RO variant was introduced in order to allow [BITFIELD]({{< relref "/commands/bitfield" >}}) behavior in read-only replicas without breaking compatibility on command flags.

See original [BITFIELD]({{< relref "/commands/bitfield" >}}) for more details.

Examples

BITFIELD_RO hello GET i8 16

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="bitfield-ro-return-info" tab1="RESP2" tab2="RESP3" >}}

Array reply: each entry being the corresponding result of the sub-command given at the same position.

-tab-sep-

Array reply: each entry being the corresponding result of the sub-command given at the same position.

{{< /multitabs >}}