Redis - Set Srem Command


Advertisements

Redis SREM command is used to remove the specified member from the set stored at the key. If the member does not exist, then the command returns 0. If the stored value at the key is not set, then an error is returned.

Return Value

Integer reply, the number of members that were removed from the set, not including nonexisting members.

Syntax

Following is the basic syntax of Redis SREM command.

redis 127.0.0.1:6379> SREM KEY MEMBER1..MEMBERN

Example

redis 127.0.0.1:6379> SADD myset1 "hello" 
(integer) 1 
redis 127.0.0.1:6379> SADD myset1 "world" 
(integer) 1 
redis 127.0.0.1:6379> SADD myset1 "bar" 
(integer) 1 
redis 127.0.0.1:6379> SREM myset1 "hello" 
(integer) 1 
redis 127.0.0.1:6379> SREM myset1 "foo" 
(integer) 0 
redis 127.0.0.1:6379> SMEMBERS myset1 
1) "bar" 
2) "world" 
redis_sets.htm
Advertisements