Returns the bit value at offset in the string value stored at a key
Offset is zero-based.
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.
GETBIT key offset.
Integer reply: 1 or 0.
- the bit value stored at offset, normal return
- -WRONGTYPE Operation against a key holding the wrong kind of value: if the data type of the key is not STRINGS
|command>||set key A A is 41 in hexadecimal and 01000001 in binary |
|command>||getbit key 6|
|command>||getbit key 7|
|command>||getbit key 100 If a bit beyond the range is specified, 0 is returned. |
GETBIT key offset
- Available since 2.2.0.
- Time complexity(Logical processing time): O(1)
To practice the command, click here to run
Redis Web Client