UK [set bit] US [sɛt bɪt]
Inlay drill bit
redis SETBIT command syntax
Function:Set or clear the bit at the specified offset for the string value stored in key. The bit is set or cleared depending on the value parameter, which can be 0 or 1 .
Syntax:SETBIT key offset value
Description:When key does not exist, a new string value is automatically generated. The string is grown to ensure that it can hold the value at the specified offset. When a string value is stretched, empty positions are filled with 0s. The offset parameter must be greater than or equal to 0 and less than 2^32 (bit mapping is limited to 512 MB).
Available versions:>= 2.2.0
Time complexity:O(1)
Return:The bit originally stored at the specified offset.
redis SETBIT command example
redis> SETBIT bit 10086 1 (integer) 0 redis> GETBIT bit 10086 (integer) 1 redis> GETBIT bit 100 # bit 默认被初始化为 0 (integer) 0