Redis String: SETBIT
SETBIT key offset value
The Redis SETBIT key is used to sets or clears the bit at offset in the string value stored at key. It is depending on value, which can be either 0 or 1. When the key does not exist, a new string value is created. The string is grown to make sure it can hold a bit at offset. The offset argument is required to be greater than or equal to 0, and smaller than 232.
Syntax:
SETBIT KEY_NAME OFFSET
Available since
2.2.0.
Return Value
Integer reply: the original bit value stored at offset.
Return Value Type
Integer
Example: Redis SETBIT
First, set a key in redis and then get it.
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
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics