Redis - String Setbit Command



Redis SETBIT command is used to set the bit value at the offset in the string value stored at the key.

Return Value

Integer, the bit value stored at the offset.

Syntax

Following is the basic syntax of Redis SETBIT command.

redis 127.0.0.1:6379> SETBIT KEY_NAME OFFSET

Example

redis 127.0.0.1:6379> SETBIT mykey 7 1 
(integer) 0 
redis 127.0.0.1:6379> GETBIT mykey 0 
(integer) 0 
redis 127.0.0.1:6379> GETBIT mykey 7 
(integer) 1 
redis 127.0.0.1:6379> GETBIT mykey 100 
(integer) 0
redis_strings.htm
Advertisements