instance method
key_matcher
Ruby on Rails 7.1.6
Since v3.0.20 PrivateSignature
key_matcher(pattern, options)
Adds the namespace defined in the options to a pattern designed to match keys. Implementations that support delete_matched should call this method to translate a pattern that matches names into one that matches namespaced keys.
Parameters
-
patternreq -
optionsreq
Source
# File activesupport/lib/active_support/cache.rb, line 785
def key_matcher(pattern, options) # :doc:
prefix = options[:namespace].is_a?(Proc) ? options[:namespace].call : options[:namespace]
if prefix
source = pattern.source
if source.start_with?("^")
source = source[1, source.length]
else
source = ".*#{source[0, source.length]}"
end
Regexp.new("^#{Regexp.escape(prefix)}:#{source}", pattern.options)
else
pattern
end
end
Defined in activesupport/lib/active_support/cache.rb line 785
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::Store