Easy Tutorial
❮ Redis Data Types Redis Benchmarks ❯

Redis Setbit Command

Redis Strings

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

Syntax

The basic syntax for 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 bit previously stored at the specified offset.

Example

redis> SETBIT bit 10086 1
(integer) 0

redis> GETBIT bit 10086
(integer) 1

redis> GETBIT bit 100   # bit is initialized to 0 by default
(integer) 0

Redis Strings

❮ Redis Data Types Redis Benchmarks ❯