I have a set of members. For example, a set called "college" with the names of 20 colleges.
Now, how to remove only a subset, for example. selected set of 10 colleges from the set?
I am starting a redis v2.4.5 server
The documentation found here http://redis.io/commands/srem says that we can delete several keys for redis> = 2.4, but still could not figure out how to achieve this.
I am working with RubyonRails and I have done this in the rails console
> $redis
> ruby-1.9.3-p0 :011 > $redis.sadd("college","champion1")
=> true
ruby-1.9.3-p0 :012 > $redis.sadd("college","champion2")
=> true
ruby-1.9.3-p0 :013 > $redis.sadd("college","champion3")
=> true
ruby-1.9.3-p0 :014 > $redis.sadd("college","champion4")
=> true
ruby-1.9.3-p0 :015 > $redis.sadd("college","champion5")
=> true
ruby-1.9.3-p0 :016 > $redis.smembers("college")
=> ["champion1", "champion2", "champion3", "champion4", "champion5"
ruby-1.9.3-p0 :017 > $redis.srem("college","champion1" "champion2")
=> false
ruby-1.9.3-p0 :018 > $redis.smembers("college")
=> ["champion1", "champion2", "champion3", "champion4", "champion5"]
Members "champion1" and "champion2" are not removed from the set.
I installed gem redis (2.2.2 ruby).
Gagan source
share