w3resource

Redis Sets: SPOP

SPOP key

Redis SPOP command is used to remove and return one or more random member from set stored at specified key.

Syntax:

SPOP KEY 

Available since:

1.0.0.

Return Value:

String reply, the removed element, or nil when a key does not exist.

Return Value Type:

Integer

Example: Redis SPOP: Imported random member from the set

127.0.0.1:6379> SADD mycolor1 "red" "green" "blue"
(integer) 3
127.0.0.1:6379> SPOP mycolor1
"red"
127.0.0.1:6379> SMEMBERS mycolor1
1) "green"
2) "blue"
127.0.0.1:6379> SPOP mycolor1
"green"
127.0.0.1:6379> SMEMBERS mycolor1
1) "blue"


Follow us on Facebook and Twitter for latest update.