> setbit mykey 1 1
> setbit mykey 7 1
When I store string value 1 and 7 into "mykey", what was exactly stored in redis? And how the getbit works inside redis?
Does anyone try to loop the bit inside this value? I know bitcount will give me number 2, but I also want to get the exact string value 1 and 7 from it, is it possible?
--
I doing some experiment by using erlang redis client to read the output.
> setbit mykey 1 1
erlang output:
<<"@">>
Then I delete this entry:
> del mykey
I do the same thing to offset 2 4 8, here you can see the mapping:
When offset is 1, the output is <<"@">>;
When offset is 2, the output is <<" ">>;
When offset is 4, the output is <<"\b">>;
When offset is 8, the output is <<0,128>>;
Honestly, I am more confused now.
Or someone can explain this "bitops.c"
-- updates ---
Maybe I should mention the reason why I want to do this to make the question more clear. We all know it will be cool to use bitmap to store online users. What I am trying to do is get the exactly user id who is online from what redis stored.
Just finished a quick version to extract offsets from redis. Please feel free to improve it.