ZPOPMAX

Syntax

  1. ZPOPMAX key [count]

Time complexity: O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.

Removes and returns up to count members with the highest 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 highest score will be the first, followed by the elements with lower scores.

Return

Array reply: list of popped elements and scores.

Examples

  1. dragonfly> ZADD myzset 1 "one"
  2. (integer) 1
  3. dragonfly> ZADD myzset 2 "two"
  4. (integer) 1
  5. dragonfly> ZADD myzset 3 "three"
  6. (integer) 1
  7. dragonfly> ZPOPMAX myzset
  8. 1) "three"
  9. 2) "3"