Reputation: 19
I'm confused how to get binary result from redis bitmap value. For example, below 5 operations executed:
setbit mykey 0 1
setbit mykey 1 0
setbit mykey 2 1
setbit mykey 3 1
setbit mykey 4 1
How can I get '10111' from redis?
Upvotes: 0
Views: 1421
Reputation: 49962
There is no Redis command that returns this type of binary representation, but you can translate the bitmap yourself.
Bitmaps are stored as regular Redis strings (i.e. byte arrays). The translation can be done in your code (method varies depending on your programming language), or with a fairly sophisticated Redis Lua script (see https://gist.github.com/itamarhaber/84815fc1d8cecebaab0ce3065dd755b1 for a related example).
Upvotes: 1