Note that there are some explanatory texts on larger screens.

plurals
  1. POPop multiple values from Redis data structure atomically?
    text
    copied!<p>Is there a Redis data structure, which would allow atomic operation of popping (get+remove) multiple elements, which it contains?</p> <p>There are well known SPOP or RPOP, but they always return a single value. Therefore, when I need first N values from set/list, I need to call the command N-times, which is expensive. Let's say the set/list contains millions of items. Is there anything like <code>SPOPM "setName" 1000</code>, which would return and remove 1000 random items from set or <code>RPOPM "listName" 1000</code>, which would return 1000 right-most items from list?</p> <p>I know there are commands like SRANDMEMBER and LRANGE, but they do not remove the items from the data structure. They can be deleted separately. However, if there are more clients reading from the same data structure, some items can be read more than once and some can be deleted without reading! Therefore, atomicity is what my question is about.</p> <p>Also, I am fine if the time complexity for such operation is more expensive. I doubt it will be more expensive than issuing N (let's say 1000, N from the previous example) separate requests to Redis server.</p> <p>I also know about separate transaction support. However, this sentence from Redis docs discourages me from using it for parallel processes modifying the set (destructively reading from it):<br> <a href="http://redis.io/commands/exec">When using WATCH, EXEC will execute commands only if the watched keys were not modified, allowing for a check-and-set mechanism.</a></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