Note that there are some explanatory texts on larger screens.

plurals
  1. POGet multiple sets
    primarykey
    data
    text
    <p>I've currently got a dataset which is something like:</p> <blockquote> <p>channel1 = user1,user2,user3</p> <p>channel2 = user4,user5,user6</p> </blockquote> <p>(<em>note- these are not actual names, the text is not a predictable sequence</em>)</p> <p>I would like to have the most optimized capability for the following:</p> <p>1) Add user to a channel</p> <p>2) Remove user from a channel</p> <p>3) Get list of all users in several selected channels, maintaining knowledge of which channel they are in (in case it matters- this can also be simply checking whether a channel has <em>any</em> users or not without getting an actual list of them)</p> <p>4) Detect if a specific user is in a channel (willing to forego this feature if necessary)</p> <p>I'm a bit hungup on the fact that there are only two ways I can see of getting multiple keys at once:</p> <p>A) Using regular keys and a mget key1, key2, key3</p> <ul> <li>In this solution, each value would be a JSON string which can then be manipulated and queried clientside to add/remove/determine values. This itself has a couple problems- firstly that it's possible another client will change the data while it's being processed (i.e. this solution is not atomic) and it's not easy to detect right away if a channel contains a specific user even though it is easy to detect if a channel has any users (this is low priority, as stated above)</li> </ul> <p>B) Using sets and sunion</p> <ul> <li>I would really like to use sets for this solution somehow, the above solution just seems wrong... but I cannot see how to query multiple sets at once and maintain info about which set each member is from or if any of the sets in the union have 0 members (sunion only gives me a final set of all the combined members)</li> </ul> <p>Any solutions which can implement the above points 1-4 in optimal time and atomic operations?</p> <p><strong>EDIT:</strong> One idea which might work in my specific case is to store the channel name as part of the username and then use sets. Still, it would be great to get a more generic answer</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.
    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