Method: Kiosk::Cacheable::Resource::ClassMethods#expires_connection_methods

Defined in:
lib/kiosk/cacheable/resource.rb

#expires_connection_methods(*methods) ⇒ Object

When a resource is explicitly expired from the cache, cache entries matching URLs to the given API method are deleted as well.



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/kiosk/cacheable/resource.rb', line 83

def expires_connection_methods(*methods)
  matchers = methods.map do |method|
    case connection.cache_key_matcher
    when :glob
      "#{api_path_to(method)}*"
    when :regexp
      /^#{Regexp.escape(api_path_to(method))}/
    end
  end

  expires_connection_keys(*matchers)
end