Latest web development tutorials

Redis Setbit command

Redis string (string)

Redis Setbit command string value to the stored key, set or clear bit (bit) on the specified offset.

grammar

redis Setbit basic command syntax is as follows:

redis 127.0.0.1:6379> Setbit KEY_NAME OFFSET

Available versions

> = 2.2.0

return value

Specified offset previously stored bits.

Examples

redis> SETBIT bit 10086 1
(integer) 0

redis> GETBIT bit 10086
(integer) 1

redis> GETBIT bit 100   # bit 默认被初始化为 0
(integer) 0

Redis string (string)