BITPOS

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Find the position of the specified bit

Usage is bitpos key bit [start [end]].
Shows the position of the specified bit as a bit offset.
start and end are byte offsets starting from 0.
Negative values can be used for start or end. In that case the last byte is -1, the previous one is -2, and so on.

Example

Command>set key ABC
Result>OK
Command>bitpos key 0
Result>0
Command>bitpos key 1
Result>1
Command>bitpos key 1 2
Result>17

View animation



Syntax

BITPOS key bit [start [end]]

  • Available since version 2.8.7.
  • Time complexity is O(N).
Related commands SETBIT, GETBIT, BITOP, BITPCOUNT
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< BITFIELD BITPOS Pub/Sub Intro >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.