SPOP

    Removes and returns one or more random members from the set value store at .

    This operation is similar to SRANDMEMBER, that returns one or more random elements from a set but does not remove it.

    When called without the count argument:

    Bulk string reply: the removed member, or nil when key does not exist.

    : the removed members, or an empty array when key does not exist.

    1. dragonfly> SADD myset "one"
    2. dragonfly> SADD myset "two"
    3. (integer) 1
    4. dragonfly> SADD myset "three"
    5. dragonfly> SPOP myset
    6. "one"
    7. dragonfly> SMEMBERS myset
    8. 1) "three"
    9. 2) "two"
    10. (integer) 1
    11. dragonfly> SADD myset "five"
    12. (integer) 1
    13. 1) "three"
    14. 2) "two"
    15. 3) "four"
    16. dragonfly> SMEMBERS myset
    17. 1) "five"

    Note that this command is not suitable when you need a guaranteed uniform distribution of the returned elements. For more information about the algorithms used for , look up both the Knuth sampling and Floyd sampling algorithms.