Skip to content

ZPOPMIN

ZPOPMIN key [count]

ZPOPMIN removes and returns the member with the lowest score from the sorted set at the specified key.

If the key does not exist, the command returns empty list. An optional “count” argument can be provided to remove and return multiple members (up to the number specified).

When popped, the elements are returned in ascending order of score and you get the rank of the element in the sorted set. The rank is 1-based, which means that the first element is at rank 1 and not rank 0. The 1), 2), 3), … is the rank of the element in the sorted set.

localhost:7379> ZADD users 10 alice 20 bob 30 charlie
OK 3
localhost:7379> ZPOPMIN users
OK
1) 10, alice
localhost:7379> ZPOPMIN users 10
OK
1) 20, bob
2) 30, charlie