instance method
delete_matched
Ruby on Rails edge
Since v5.2.8.1Signature
delete_matched(matcher, options = nil)
Cache Store API implementation.
Supports Redis KEYS glob patterns:
h?llo matches hello, hallo and hxllo
h*llo matches hllo and heeeello
h[ae]llo matches hello and hallo, but not hillo
h[^e]llo matches hallo, hbllo, ... but not hello
h[a-b]llo matches hallo and hbllo
Use \ to escape special characters if you want to match them verbatim.
See redis.io/commands/KEYS for more.
Failsafe: Raises errors.
Parameters
-
matcherreq -
optionsopt = nil
Source
# File activesupport/lib/active_support/cache/redis_cache_store.rb, line 210
def delete_matched(matcher, options = nil)
unless String === matcher
raise ArgumentError, "Only Redis glob strings are supported: #{matcher.inspect}"
end
pattern = namespace_key(matcher, options)
instrument :delete_matched, pattern do
redis.nodes.each do |node|
node.with do |conn|
conn.scan(match: pattern, count: SCAN_BATCH_SIZE).each_slice(SCAN_BATCH_SIZE).each do |keys|
conn.call("unlink", *keys)
end
end
end
end
end
Defined in activesupport/lib/active_support/cache/redis_cache_store.rb line 210
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::RedisCacheStore