Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As I see it, each method has its own benefits and drawbacks:</p> <p>The hash method:</p> <ul> <li>You can get a list of all emails (keys) or ID's (values) fairly quickly (O(N), where N is the number of entries in the map)</li> <li>For small number of entries, it will be quite memory efficient (pretty small though, probably not applicable for any real use-cases)</li> <li>You are limited to 2^32-1 entries (again, might not be an issue, unless you plan on a majority of the people on earth to use your application)</li> <li><em>slightly</em> slower, since redis needs to do two O(1) lookups instead of just one... Marginal difference, if at all noticeable. </li> <li>Not shard friendly, since they will all be in the same redis instance.</li> </ul> <p>The key method:</p> <ul> <li>No limit to number of entries</li> <li>As fast as it's going to be</li> <li>Only possible to get a list of all users by using <code>KEY</code>, which is O(n) (for each entry in the database - a big no-no for live environments)</li> <li>Shard friendly</li> </ul> <p>Those are all the differences I can think of. I tend to lean towards the key method unless I need to list all users for some reason, just because it's more straight-forward and scales better with sharding.</p> <p>As an aside, I would probably not store JSON data as the user data if I can avoid it, because it will likely be more memory-efficient to store the fields in a hash. Also, you can just get and set the fields you really need a certain point, rather than the whole blob. It's also possible to do increments in the hash atomically without transactions, which can be useful. But it all depends on your data... If you have a large nested structure, it might be easiest to just serialize it and throw it in there instead of creating lots of different native structures and link them together.</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