"Redis bit Operation "
1.getbit Key Offset
keygets the bitwise (BIT) on the stored string value for the specified offset.
Returned when the offset length of the string value is greater than or key does not exist 0 .
2.setbit key Offset value
keySets or clears the bit (bit) on the specified offset for the stored string value.
The setting or clearing of bits depends on the value parameters, which can be or 0 can be 1 .
keyautomatically generates a new string value when it does not exist.
The string is stretched (grown) to ensure that it can be value saved at the specified offset. When a string value is stretched, a blank position is 0 filled.
offsetparameter must be greater than or equal 0 to less than 2^32 (bit mapping is limited to within MB).
For large offset setbit operations, memory allocation may cause the Redis server to be blocked. Refer specifically to the SETRANGE command, Warning (warning) section.
3,bitop operation Destkey key [key ...]
A bitwise operation is performed on one or more strings that hold bits key , and the results are saved to the destkey top.
operationCan be AND ,,, OR any of NOT XOR these four operations:
BITOP AND destkey key [key ...], the logic is calculated for one or more, and the key results are saved to destkey .
BITOP OR destkey key [key ...], the logical OR of one or more key , and the result is saved to destkey .
BITOP XOR destkey key [key ...], the logical XOR of one or more key , and the result is saved to destkey .
BITOP NOT destkey key, the logic for the given is key not, and the result is saved to destkey .
In addition NOT to operations, other operations can accept one or more key as input.
4,bitop operation Destkey key [key ...]
A bitwise operation is performed on one or more strings that hold bits key , and the results are saved to the destkey top.
operationCan be AND ,,, OR any of NOT XOR these four operations:
BITOP AND destkey key [key ...], the logic is calculated for one or more, and the key results are saved to destkey .
BITOP OR destkey key [key ...], the logical OR of one or more key , and the result is saved to destkey .
BITOP XOR destkey key [key ...], the logical XOR of one or more key , and the result is saved to destkey .
BITOP NOT destkey key, the logic for the given is key not, and the result is saved to destkey .
In addition NOT to operations, other operations can accept one or more key as input.
Handling strings of different lengths
When Bitop handles strings of different lengths, the missing part of the shorter string is considered 0 .
Empty is key also considered to be a 0 string sequence of inclusions.
Reference: http://redisdoc.com/index.html
Redis bit operation