Redis Getbit Command
The Redis Getbit command is used to obtain the bit at a specified offset from the string value stored at key.
Syntax
The basic syntax of the Redis Getbit command is as follows:
redis 127.0.0.1:6379> GETBIT KEY_NAME OFFSET
Available Versions
>= 2.2.0
Return Value
The bit at the specified offset in the string value.
Returns 0 when the offset OFFSET is greater than the length of the string value, or when the key does not exist.
Examples
# 对不存在的 key 或者不存在的 offset 进行 GETBIT, 返回 0 redis> EXISTS bit (integer) 0 redis> GETBIT bit 10086 (integer) 0 # 对已存在的 offset 进行 GETBIT redis> SETBIT bit 10086 1 (integer) 0 redis> GETBIT bit 10086 (integer) 1Other Extensions
Redis Strings