SREM

AttentionThis page documents an earlier version. Go to the latest (v2.1)version.

Synopsis

SREM key value [value …]This command removes one or more specified members from the set that is associated with the given key.

  • If the key does not exist, the associated set is an empty set, and the return value is zero.
  • If the key is associated with a value that is not a set, an error is raised.
  • If a specified value does not exist in the given set, that value is ignored and not counted toward the total of removed members.

Return Value

Returns the total number of existed members that were removed from the set.

Examples

You can do this as shown below.

  1. $ SADD yuga_world "America"
  1. 1
  1. $ SADD yuga_world "Moon"
  1. 1
  1. $ SREM yuga_world "Moon"
  1. 1
  1. $ SREM yuga_world "Moon"
  1. 0

See Also

sadd, scard, sismember, smembers