ashish-goyal / redis

Automatically exported from code.google.com/p/redis
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

implement ZPOP / ZREVPOP #251

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
feature request:
native zpop / zrevpop commands that allow pop'ing of the lowest / the highest 
scored element 
from a zset

Original issue reported on code.google.com by marc.see...@gmail.com on 28 May 2010 at 5:23

GoogleCodeExporter commented 8 years ago
Hello Marc,

you don't need this anymore probably as we have a "WATCH" command that allows 
to build atomic commands 
with optimistic locking on top of the other commands. You can find more 
information in the MULTI/EXEC man 
page. The only problem with a ZPOP implemented this way is if there is a lot of 
contention (that is, a number 
of clients against the same key, many times/second).

Cheers,
Salvatore

Original comment by anti...@gmail.com on 28 May 2010 at 5:28

GoogleCodeExporter commented 8 years ago
I'm using a redis zset as a weighted queue and a lot of parallel processes are 
accessing it :)
In general, I'd just be convenient to have it in redis (even if it's WATCH 
based internally) so people don't have to 
implement it themselves :)

p.s. awesome work!

Original comment by marc.see...@gmail.com on 28 May 2010 at 5:34

GoogleCodeExporter commented 8 years ago
Ok, this will be added at some point in 2.x.x (but after 2.2.0), accepted.

Cheers,
Salvatore

Original comment by anti...@gmail.com on 31 Aug 2010 at 11:00

GoogleCodeExporter commented 8 years ago
Here is my attempt at ZPOP and ZREVPOP.  Both take an optional score argument 
as applicable - ZPOP myzset 30 will only pop an element with a score >= 30, and 
ZREVPOP myzset 30 will only pop an element with a score <= 30.

https://github.com/bohford/redis/tree/zpop

Original comment by bohf...@gmail.com on 30 Dec 2010 at 6:51

GoogleCodeExporter commented 8 years ago
Pieter provides this nice solution with the current command set.

http://groups.google.com/group/redis-db/browse_thread/thread/babf54f28f92928d?pl
i=1

Original comment by moonpiesandbox on 4 Mar 2011 at 9:34

GoogleCodeExporter commented 8 years ago
Since now scripting is available, I quickly wrote up a blog post with the 
implementation of zpop and zrevpop here 
http://sunilarora.org/redis-lua-scripting

Original comment by arora.su...@gmail.com on 20 Jun 2011 at 3:17

GoogleCodeExporter commented 8 years ago
+1 on this. Is there an update on when ZPOP/ZREVPOP will be implemented?  

Original comment by proten...@gmail.com on 8 Feb 2014 at 8:33

GoogleCodeExporter commented 8 years ago
This google project is outdated. Please report the issue on 
https://github.com/antirez/redis

Original comment by jeredi...@gmail.com on 8 Feb 2014 at 8:51