You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would return bar, probably also the score or one would split the operations to return either the score or the member.
Reacted by Roman Starkov, David Gray, Pavel <Ven> Gulbin, Montana Flynn, danilo, Алексей Трофимов, Martin Schrimpf, Marco, Toby Heighway, Olayinka and 12 more
Probably a zrpop would also make sense, maybe even zblpop and zbrpop, which would allow for example creating a queue of repeatedly run tasks, which are ordered and processed based off timestamps.
Reacted by Rémi Bèges, Montana Flynn, Tomasz Sawicki and Cole Chamberlain
blocking pop from sorted set makes it easy to implement priority queues with low latency.
Reacted by Roman Imankulov, Mitch Broadhead, Joe Kaufeld, Thanos Polychronakis, Lee Hickey, hbc, James Katz, Arjen Jonathan, David Gray, Christopher Lee and 9 more
I came up with a workaround, for the situation where you need to pop() from a sorted list in a transactional way to prevent races, specifically for the case when the delete command relies on the output of the first select command. So first, you use zrange or something else to get the element that is to be 'popped', after that returns the response, assign a reference to it in memory, then use zrem to delete the element by its value (since we now have a reference to it), and now here's the trick: If zrem returns 0, then that means we've encountered a race condition, and a different reader 'popped' the same element at almost the exact same time, but beat us to it just barely. So in this case, since we know the other reader successfully deleted the element we were about to delete, we simply do a recursive call the function we're in, to try again from the beginning. Needless to say, if zrem returned a 1, then we know that we've successfully read and deleted the same element, without a race interference, and can safely return the popped element.
Activity
reezer commentedon Jan 10, 2015
Probably a zrpop would also make sense, maybe even zblpop and zbrpop, which would allow for example creating a queue of repeatedly run tasks, which are ordered and processed based off timestamps.
badboy commentedon Jan 10, 2015
workaround for now:
(
-1, -1forzrpopequivalent)reezer commentedon Jan 10, 2015
blocking would be cool though
halaei commentedon Oct 8, 2015
blocking pop from sorted set makes it easy to implement priority queues with low latency.
warrickhill commentedon Sep 27, 2016
+1
chrisharrison commentedon Nov 2, 2016
+1
jmb0z commentedon Nov 9, 2016
+1
merkylove commentedon Nov 25, 2016
+1)
james727 commentedon Dec 2, 2016
+1
rubberpants commentedon Feb 21, 2017
+1 This would be very nice to have.
rfyiamcool commentedon Mar 30, 2017
+1
tirkarthi commentedon Apr 4, 2017
Following links might help :
http://redismodules.com/modules/rxzsets/
http://redismodules.com/commands/zpop/
denengineer commentedon Aug 1, 2017
+1
ChefAndy commentedon Sep 12, 2017
+1
rfyiamcool commentedon Oct 12, 2017
+1
welovelain commentedon Dec 28, 2017
+1
lausycampari commentedon Mar 9, 2018
I came up with a workaround, for the situation where you need to pop() from a sorted list in a transactional way to prevent races, specifically for the case when the delete command relies on the output of the first select command. So first, you use
zrangeor something else to get the element that is to be 'popped', after that returns the response, assign a reference to it in memory, then usezremto delete the element by its value (since we now have a reference to it), and now here's the trick: Ifzremreturns 0, then that means we've encountered a race condition, and a different reader 'popped' the same element at almost the exact same time, but beat us to it just barely. So in this case, since we know the other reader successfully deleted the element we were about to delete, we simply do a recursive call the function we're in, to try again from the beginning. Needless to say, ifzremreturned a 1, then we know that we've successfully read and deleted the same element, without a race interference, and can safely return the popped element.sknuell commentedon Apr 6, 2018
+1
wluo commentedon Apr 25, 2018
+sqrt(-1)
Implements [B]Z[REV]POP and the respective unit tests
itamarhaber commentedon May 14, 2018
@here please review https://github.com/antirez/redis/pull/4879 and the accompanying doc PR redis/redis-doc#922
Implements [B]Z[REV]POP and the respective unit tests
Implements [B]Z[REV]POP and the respective unit tests