diff options
Diffstat (limited to 'iredis/data/commands/bitop.md')
-rw-r--r-- | iredis/data/commands/bitop.md | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/iredis/data/commands/bitop.md b/iredis/data/commands/bitop.md index 656befa..d35c756 100644 --- a/iredis/data/commands/bitop.md +++ b/iredis/data/commands/bitop.md @@ -4,13 +4,14 @@ store the result in the destination key. The `BITOP` command supports four bitwise operations: **AND**, **OR**, **XOR** and **NOT**, thus the valid forms to call the command are: -- `BITOP AND destkey srckey1 srckey2 srckey3 ... srckeyN` -- `BITOP OR destkey srckey1 srckey2 srckey3 ... srckeyN` -- `BITOP XOR destkey srckey1 srckey2 srckey3 ... srckeyN` -- `BITOP NOT destkey srckey` + +* `BITOP AND destkey srckey1 srckey2 srckey3 ... srckeyN` +* `BITOP OR destkey srckey1 srckey2 srckey3 ... srckeyN` +* `BITOP XOR destkey srckey1 srckey2 srckey3 ... srckeyN` +* `BITOP NOT destkey srckey` As you can see **NOT** is special as it only takes an input key, because it -performs inversion of bits so it only makes sense as an unary operator. +performs inversion of bits so it only makes sense as a unary operator. The result of the operation is always stored at `destkey`. @@ -27,8 +28,8 @@ zero bytes up to the length of the longest string. @integer-reply -The size of the string stored in the destination key, that is equal to the size -of the longest input string. +The size of the string stored in the destination key, that is equal to the +size of the longest input string. @examples @@ -42,20 +43,20 @@ GET dest ## Pattern: real time metrics using bitmaps `BITOP` is a good complement to the pattern documented in the `BITCOUNT` command -documentation. Different bitmaps can be combined in order to obtain a target -bitmap where the population counting operation is performed. +documentation. +Different bitmaps can be combined in order to obtain a target bitmap where +the population counting operation is performed. See the article called "[Fast easy realtime metrics using Redis -bitmaps][hbgc212fermurb]" for a interesting use cases. +bitmaps][hbgc212fermurb]" for an interesting use cases. -[hbgc212fermurb]: - http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps +[hbgc212fermurb]: http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps ## Performance considerations -`BITOP` is a potentially slow command as it runs in O(N) time. Care should be -taken when running it against long input strings. +`BITOP` is a potentially slow command as it runs in O(N) time. +Care should be taken when running it against long input strings. For real-time metrics and statistics involving large inputs a good approach is -to use a replica (with read-only option disabled) where the bit-wise operations -are performed to avoid blocking the master instance. +to use a replica (with read-only option disabled) where the bit-wise +operations are performed to avoid blocking the master instance. |