SREM

Syntax

  1. SREM key member [member ...]

Time complexity: O(N) where N is the number of members to be removed.

ACL categories: @write, @set, @fast

Remove the specified members from the set stored at key. Specified members that are not a member of this set are ignored. If key does not exist, it is treated as an empty set and this command returns 0.

An error is returned when the value stored at key is not a set.

Return

Integer reply: the number of members that were removed from the set, not including non existing members.

Examples

  1. dragonfly> SADD myset "one"
  2. (integer) 1
  3. dragonfly> SADD myset "two"
  4. (integer) 1
  5. dragonfly> SADD myset "three"
  6. (integer) 1
  7. dragonfly> SREM myset "one"
  8. (integer) 1
  9. dragonfly> SREM myset "four"
  10. (integer) 0
  11. dragonfly> SMEMBERS myset
  12. 1) "three"
  13. 2) "two"