ZMPOP

Since 1.1.0Sorted sets

Syntax

ZMPOP numkeys key [key ...] MIN|MAX [COUNT count]
  • Flags: movablekeys, write
  • ACL categories: @slow, @sortedset, @write
  • Arity: -4

Pops members from the first of the given sorted sets that is not empty: the lowest (MIN) or highest (MAX) scores, one or COUNT count of them. numkeys is how many keys follow.

Reply

  • A two-element array: the key, and an array of [member, score] pairs.
  • nil if every sorted set is empty.

Examples

> ZADD p 2 b
(integer) 1
> ZMPOP 2 empty p MAX
1) "p"
2) 1) 1) "b"
      2) "2"
> ZMPOP 1 empty MIN
(nil)