class RediSet::Client
Attributes
redis[R]
Public Class Methods
new(redis: nil, redis_config: nil)
click to toggle source
# File lib/redi_set/client.rb, line 5 def initialize(redis: nil, redis_config: nil) if redis @redis = redis elsif redis_config @redis = Redis.new(redis_config) else fail ArgumentError, "redis or redis_config must be supplied to the RediSet::Client" end end
Public Instance Methods
match(constraint_hash)
click to toggle source
# File lib/redi_set/client.rb, line 15 def match(constraint_hash) RediSet::Query.from_hash(constraint_hash).execute(@redis) end
set_all!(attribute_name, quality_name, ids)
click to toggle source
# File lib/redi_set/client.rb, line 19 def set_all!(attribute_name, quality_name, ids) attribute = Attribute.new(name: attribute_name) quality = Quality.new(attribute: attribute, name: quality_name) quality.set_all!(@redis, ids) end
set_details!(id, details)
click to toggle source
details here is a three-layer hash: attribute_name => quality_name => boolean. only specified attribute/qualities will be updated.
# File lib/redi_set/client.rb, line 27 def set_details!(id, details) possessed_qualities, lacked_qualities = Quality.collect_from_details(details) @redis.multi do possessed_qualities.each { |q| @redis.sadd(q.key, id) } lacked_qualities.each { |q| @redis.srem(q.key, id) } end end