hiddenid01 / redis

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

[Feature Request] #401

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
ZADDLT / ZADDGT

Right now, if you ZADD something with a new score, it updates the score.  We 
want to allow multiple inserts and only see the most recent item.  We could 
cleanly do this if there was a ZADDLT command.

ZADDLT score data

would add the data if it didn't exist and update the score If and only if the 
score was less than the current value.

This would have a huge set of synchronization problems with multiple writers.

Thanks Antirez.

Original issue reported on code.google.com by d...@dangould.com on 10 Dec 2010 at 8:03

GoogleCodeExporter commented 9 years ago
I wonder if you could achieve the same behavior using WATCH?

WATCH zset
score = ZSCORE zset element
if score == nil or score < new_score
  MULTI
  ZADD zset new_score element
  EXEC
else
  UNWATCH
end

Original comment by damian.j...@gmail.com on 13 Dec 2010 at 12:11

GoogleCodeExporter commented 9 years ago

Original comment by damian.j...@gmail.com on 13 Dec 2010 at 12:13

GoogleCodeExporter commented 9 years ago
Agreed, though we want to do *many* of these ops and the watch seems  
inelegant/expensive.

Original comment by d...@dangould.com on 13 Dec 2010 at 12:26

GoogleCodeExporter commented 9 years ago
IMHO, WATCH is definitely what should be used here, and it isn't all that 
expensive. I don't want to speak for all users of Redis, but I feel like ZADDLT 
is not an operation that many users will utilize.  Nevertheless, look at how 
many "commands" (loosely speaking) a MySQL Server supports.

Original comment by compwiz...@gmail.com on 24 Jun 2011 at 3:29