class ActiveSupport::Cache::RedisSetStore::SetOwner
Redis set wrapper for a given partition.
Public Class Methods
new(set_owner_regexp, key, redis)
click to toggle source
# File lib/active_support/cache/redis_set_store.rb, line 123 def initialize(set_owner_regexp, key, redis) @key = key @set = nil match = set_owner_regexp.match(key) @set = match[0] if match @redis = redis @redis_set_store = STORE if defined?(STORE) @redis_set_store ||= @redis end
Public Instance Methods
convert_wildcards_to_regex()
click to toggle source
Redis wildcard character “*” is converted to the Regexp “.*”. All other special characters are normally-escaped.
# File lib/active_support/cache/redis_set_store.rb, line 161 def convert_wildcards_to_regex key = Regexp.escape(@key.to_s) key = key.to_s.gsub("\\*", ".*") key << "$" end
delete_matched()
click to toggle source
# File lib/active_support/cache/redis_set_store.rb, line 143 def delete_matched return unless @set && @key srem_list = matched return if srem_list.blank? @redis_set_store.srem(@set, srem_list) @redis.del(srem_list) end
matched()
click to toggle source
# File lib/active_support/cache/redis_set_store.rb, line 153 def matched return unless @set && @key matcher_regexp = Regexp.compile(convert_wildcards_to_regex) @redis_set_store.smembers(@set).select { |smember| matcher_regexp.match(smember) } end
sadd()
click to toggle source
# File lib/active_support/cache/redis_set_store.rb, line 133 def sadd return unless @set && @key @redis_set_store.sadd(@set, @key) end
srem()
click to toggle source
# File lib/active_support/cache/redis_set_store.rb, line 138 def srem return unless @set && @key @redis_set_store.srem(@set, @key) end