BITPOS

Finds the position of the first matching bit.

Bitmaps · Example verified

Syntax covered here

BITPOS key bit

The case searches for bit 1 across the value and finds the offset previously set by SETBIT.

Tested example & replies

Requests below run in order against an empty database. Each connection authenticates with the fixture password first. Quoted values are strings; null is a nil reply; arrays preserve RESP order.

# connection: default
> SETBIT bits 1 1
0
# connection: default
> BITPOS bits 1
1