修改本页
Redis

SPOP key

Removes and returns a random element from the set value stored at key.

This operation is similar to SRANDMEMBER, that returns a random element from a set but does not remove it.

返回值

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

例子

redis>  SADD myset "one"
(integer) 1
redis>  SADD myset "two"
(integer) 1
redis>  SADD myset "three"
(integer) 1
redis>  SPOP myset
"one"
redis>  SMEMBERS myset
1) "three"
2) "two"
redis> 
Comments powered by Disqus