Saturday, 11 April 2015

BITOP : Perform bit operation on strings


Syntax
BITOP operation destkey key1 key2 ... keyN

Perform a bitwise operation between multiple keys and store the result in the destination key. BITOP command support all bitwise operations like AND, OR, XOR and NOT.

Returns
The size of the string stored in the destination key.

Examples
BITOP AND destkey key1 key2 key3 ... keyN
BITOP OR destkey destkey key1 key2 key3 ... keyN
BITOP XOR destkey destkey key1 key2 key3 ... keyN
BITOP NOT destkey key1

127.0.0.1:6379> set key1 'a' 
OK 
127.0.0.1:6379> set key2 'b' 
OK 
127.0.0.1:6379> set key3 'c' 
OK 
127.0.0.1:6379> bitop or destkey key1 key2 key3 
(integer) 1 
127.0.0.1:6379> get destkey 
"c" 
127.0.0.1:6379> bitop and destkey key1 key2 key3 
(integer) 1 
127.0.0.1:6379> get destkey 
"`" 
127.0.0.1:6379> bitop not destkey key1 
(integer) 1 
127.0.0.1:6379> get destkey 
"\x9e" 
127.0.0.1:6379> 

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment