SPOP

Since 1.1.0Sets

Syntax

SPOP key [count]
  • Flags: fast, write
  • ACL categories: @fast, @set, @write
  • Arity: -2

Removes and returns members of the set at key, picked at random. A set left empty is deleted.

Reply

  • Without count: a member, or nil if the key does not exist.
  • With count: an array of up to count members; empty if the key does not exist.

Examples

> SADD s a b c
(integer) 3
> SPOP s
"c"
> SPOP s 5
1) "b"
2) "a"
> EXISTS s
(integer) 0