Storing List<Integer> into Redis as a bitmap

75 Views Asked by At

I want to store a List<Integer> into redis using the set command(instead of the setbit that I will have to do many times hence increasing the no of commandds).I want to use the bitmap way by setting the offset in a particular key.

I am trying to do this by converting


> BitSet bitset = new BitSet();
> for(Integer user:users){
> bitset.set(user);
> }

and then converting to byte[] by doing

byte[] byteArray = bitSet.toByteArray();

I am using the RedisSerializer.byteArray() to serialize the value and store the byte[]

But this is not setting the correct offsets hence wrong data is being stored. Could anyone please help with us? Thanks in advance

0

There are 0 best solutions below