SETBIT

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

Set a bit

offset starts from 0. value can be only 0 or 1.
It returns the original bit value.
The example uses letters, but you can use this to manage an attendance list. If attendance is high, it saves memory.

Example

Command>set key A
Result>OK
Command>setbit key 6 1
Result>0
Command>get key
Result>C

View animation



Syntax

SETBIT key offset value

  • Available since version 2.2.0.
  • Time complexity is O(1).
Related commands GETBIT, BITOP, BITCOUNT, BITPOS
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< LOLWUT SETBIT GETBIT >>

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