0

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?

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I got the number with bitfield command and translate it to binary string in code, the command for this scenario is : bitfield mykey get u5 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.