kevy4.0

SPOP

Remove and return one or more random members of a set.

SPOP key [count]
Group
Set
Since
1.0.0
Arity
at least 2
Flags
write

Complexity

O(count) expected; draining an N-member set with N calls is O(N^2) because the bucket scan restarts each time

Complexity and compatibility are read out of kevy's implementation, not copied from Redis's reference. Several genuinely differ.

Redis compatibility

Differs

members are NOT random — SPOP returns the first members in hash-bucket order and the seed is a fixed constant, so repeated SPOP on the same set is fully deterministic

See also

SADDSCARDSDIFFSDIFFSTORESINTERSINTERSTORESISMEMBERSMEMBERSSRANDMEMBERSREMSSCANSUNIONSUNIONSTORE

← All commands