Note that there are some explanatory texts on larger screens.

plurals
  1. POredis - Using Hashes
    text
    copied!<p>I'm implementing a social stream and a notification system for my web application by using redis. I'm new to redis and I have some doubts about hashes and their efficiency.</p> <p>I've read this awesome <a href="http://instagram-engineering.tumblr.com/post/12202313862/storing-hundreds-of-millions-of-simple-key-value-pairs" rel="nofollow">Instagram post</a> and I planned to implement their similar solution for minimal storage.</p> <p>As mentioned in their blog, they did like this</p> <blockquote> <p>To take advantage of the hash type, we bucket all our Media IDs into buckets of 1000 (we just take the ID, divide by 1000 and discard the remainder). That determines which key we fall into; next, within the hash that lives at that key, the Media ID is the lookup key <em>within</em> the hash, and the user ID is the value. An example, given a Media ID of 1155315, which means it falls into bucket 1155 (1155315 / 1000 = 1155):</p> </blockquote> <pre><code>HSET "mediabucket:1155" "1155315" "939" HGET "mediabucket:1155" "1155315" &gt; "939" </code></pre> <p>So Instead of having <strong>1000 seperate keys</strong> they are storing it in <strong>one hash with thousand lookup keys</strong>. And <strong>my doubt</strong> is why can't we increase the lookup key values to even more larger.</p> <p><strong>For eg:</strong> <code>Media ID of 1155315 will fall into mediabucket:115 by dividing it by 10000</code> or even greater than that.</p> <p>Why are they settling with one hash bucket with 1000 lookup keys. Why can't they have <strong>one hash bucket with 100000 lookup keys</strong>. Is that related to <strong>efficiency</strong>?</p> <p>I need your suggestion for implementing the efficient method in my web application.</p> <p>P.S. Please! don't say that stackoverflow is not for asking suggestions and I don't know where to find help.</p> <p>Thanks!</p>
 

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