Redis Getbit command
The Redis Getbit command is used to get the bit at a specified offset of the string value stored in key.
Syntax
The basic syntax of the redis Getbit command is as follows:
redis 127.0.0.1:6379> GETBIT KEY_NAME OFFSET
Available Version
= 2.2.0
Return Value
The bit at the specified offset of the string value.
Returns 0 when the offset is greater than the length of the string value, or when the key does not exist.
Example
# Return 0 when GETBIT is called with a non-existent key or offset
redis> EXISTS bit
(integer) 0
redis> GETBIT bit 10086
(integer) 0
# GETBIT the existing offset
redis> SETBIT bit 10086 1
(integer) 0
redis> GETBIT bit 10086
(integer) 1
Redis string