I suspect bitmaps are your best hope.
In my experience, redis is a great server for bitmaps; you must use the string data structure (one of the five data structures available in redis)
many, or possibly all of the operations you need to perform, are available out of the box in redis, like atomic operations
operation redis setbit has a time complexity of O (1)
In a typical implementation, you need to hash the values ββof your array to offset the values ββin the bit string, then set each bit to its corresponding offset (or index); So:
>>> r1.setbit('k1', 20, 1)
the first argument is the key, the second is the offset (index value), and the third is the value in that index on the bitmap.
to find out if a bit is set at this offset (20), a getbit call passing in the key for the bit string.
>>> r1.getbit('k1', 20)
then on these bitmap images you can, of course, perform the usual bitwise operations, for example, logical AND, OR, XOR.
source share