GETBIT

Syntax

1. GETBIT key offset

Time complexity: O(1)

Returns the bit value at offset (zero-indexed) in the string value stored at key.

When offset is beyond the string length, the string is assumed to be a contiguous space with 0 bits. When key does not exist it is assumed to be an empty string, so offset is always out of range and the value is also assumed to be a contiguous space with 0 bits.

Return

Integer reply: the bit value stored at offset.

Examples

1. dragonfly> SET mykey "\x42"  # 0100'0010
2. dragonfly> GETBIT mykey 0
3. (integer) 0
4. dragonfly> GETBIT mykey 1
5. (integer) 1
6. dragonfly> GETBIT mykey 6
7. (integer) 1
8. dragonfly> GETBIT mykey 100
9. (integer) 0