Returns the lowest-scoring members from a sorted set after removing them. Deletes the sorted set if the last member was popped.
ZPOPMIN
key
[count]
Removes and returns up to count
members with the lowest
scores in the sorted set stored at key
.
When left unspecified, the default value for count
is 1.
Specifying a count
value that is higher than the sorted
set’s cardinality will not produce an error. When returning multiple
elements, the one with the lowest score will be the first, followed by
the elements with greater scores.
O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.
@fast @sortedset @write
127.0.0.1:6379> ZADD myzset 1 "one"
(integer) 1
127.0.0.1:6379> ZADD myzset 2 "two"
(integer) 1
127.0.0.1:6379> ZADD myzset 3 "three"
(integer) 1
127.0.0.1:6379> ZPOPMIN myzset
1) "one"
2) "1"
BZMPOP, BZPOPMAX, BZPOPMIN, ZADD, ZCARD, ZCOUNT, ZDIFF, ZDIFFSTORE, ZINCRBY, ZINTER, ZINTERCARD, ZINTERSTORE, ZLEXCOUNT, ZMPOP, ZMSCORE, ZPOPMAX, ZRANDMEMBER, ZRANGE, ZRANGESTORE, ZRANK, ZREM, ZREMRANGEBYLEX, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZREVRANK, ZSCAN, ZSCORE, ZUNION, ZUNIONSTORE.