Note that there are some explanatory texts on larger screens.

plurals
  1. POCan someone explain redis setbit command?
    primarykey
    data
    text
    <pre><code>&gt; setbit mykey 1 1 &gt; setbit mykey 7 1 </code></pre> <p>When I store string value 1 and 7 into "mykey", <strong>what was exactly stored in redis</strong>? And how the getbit works inside redis?</p> <p><strong>Does anyone try to loop the bit inside this value?</strong> 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?</p> <p>--</p> <p>I doing some experiment by using erlang redis client to read the output.</p> <pre><code>&gt; setbit mykey 1 1 </code></pre> <p>erlang output:</p> <pre><code>&lt;&lt;"@"&gt;&gt; </code></pre> <p>Then I delete this entry:</p> <pre><code>&gt; del mykey </code></pre> <p>I do the same thing to offset 2 4 8, here you can see the mapping:</p> <pre><code>When offset is 1, the output is &lt;&lt;"@"&gt;&gt;; When offset is 2, the output is &lt;&lt;" "&gt;&gt;; When offset is 4, the output is &lt;&lt;"\b"&gt;&gt;; When offset is 8, the output is &lt;&lt;0,128&gt;&gt;; </code></pre> <p>Honestly, I am more confused now.</p> <p>Or someone can explain this <a href="https://github.com/antirez/redis/blob/ec7f480e11e1b697c05ac40d69a6a9fca88fc439/src/bitops.c" rel="nofollow">"bitops.c"</a></p> <p>-- updates ---</p> <p>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.</p> <p><strong>Just finished a <a href="https://github.com/JoshuaChi/extract-offsets-from-redis-bitmap" rel="nofollow">quick version</a> to extract offsets from redis. Please feel free to improve it.</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload