Nan Wang
Nan Wang

Reputation: 19

How to get binary string from redis bitmap?

I'm confused how to get binary result from redis bitmap value. For example, below 5 operations executed:

How can I get '10111' from redis?

Upvotes: 0

Views: 1421

Answers (1)

Itamar Haber
Itamar Haber

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

Related Questions