Latest web development tutorials

Redis Srem command

Redis set (Set)

Redis Srem command is used to remove the collection of one or more members of the element, the element is not present members will be ignored.

When the key is not a collection type, an error is returned.

In Redis 2.4 the previous version, SREM accepts only individual members value.

grammar

redis Srem basic command syntax is as follows:

redis 127.0.0.1:6379> SREM KEY MEMBER1..MEMBERN

Available versions

> = 1.0.0

return value

The number has been successfully removed the element, not including the neglected element.

Examples

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 set (Set)