Search code examples
javascriptbitmapredisioredis

How to set a value in a bitmap and retrieve a bitmap from redis using ioredis?


I would like to use a Redis bitmap to represent values.

If I have an integer value then I want to be able to set the corresponding index of the bitmap to 1 or true.

I also want to be able to retrieve the entire bitmap and walk it to identify the positions of the "ones".

There is a bitfield data structure in Redis, but I don't understand the documentation.

There are the following commands:

BITFIELD GET <type> <offset>
BITFIELD SET <type> <offset> <value>

What is the <type> field? What value should I use for <value> (string 1?).

Finally, can anyone help me with the syntax for these commands when using ioredis?


Solution

  • Idk, but I'd go w/ 8 instinctively