title: Concurrent priority queue in redis?
body: <p>I would like to implement a concurrent priority queue in Redis, with multiple processes on different machines adding items (with scores) and multiple other processes popping these items, lowest score first.</p>
  
  <p>A simple queue can be implemented with LPUSH and RPOP.</p>
  
  <p>Using a ZSET, I can add the items using ZADD and pop them with ZRANGE and ZREM, as long as there is only one reader.</p>
  
  <p>For multiple readers I think I need something like ZPOP which combines ZRANGE and ZREM in a single atomic operation.  Otherwise two readers may get the same item from ZRANGE before either can ZREM it.  Retrying if ZREM returns 0 would work but is not desirable.</p>
  
  <p>Is there some way I can do this using the current Redis commands?  Is there any reason this hasn't been added to Redis already?  It seems like it would be a pretty simple command to implement.</p>