Redis Setbit Command

Redis String

The Redis Setbit command is used to set or clear the bit at the specified offset in the string value stored at key.

Syntax

The basic syntax of the Redis Setbit command is as follows:

redis 127.0.0.1:6379> Setbit KEY_NAME OFFSET

Available Versions

>= 2.2.0

Return Value

The original bit value stored at the specified offset.

Example

redis> SETBIT bit 10086 1
(integer) 0

redis> GETBIT bit 10086
(integer) 1

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

Redis String

Other Extensions