instance method
expire_fragment
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v4.2.9Signature
expire_fragment(key, options = nil)
Name can take one of three forms:
-
String: This would normally take the form of a path like “pages/45/notes”
-
Hash: Is treated as an implicit call to url_for, like { :controller => “pages”, :action => “notes”, :id => 45 }
-
Regexp: Will destroy all the matched fragments, example:
%r{pages/\d*/notes}Ensure you do not specify start and finish in the regex (^$) because the actual filename matched looks like ./cache/filename/path.cache Regexp expiration is only supported on caches that can iterate over all keys (unlike memcached).
Parameters
-
keyreq -
optionsopt = nil
Source
# File actionpack/lib/action_controller/caching/fragments.rb, line 95
def expire_fragment(key, options = nil)
return unless cache_configured?
key = key.is_a?(Regexp) ? key : fragment_cache_key(key)
if key.is_a?(Regexp)
self.class.benchmark "Expired fragments matching: #{key.source}" do
cache_store.delete_matched(key, options)
end
else
self.class.benchmark "Expired fragment: #{key}" do
cache_store.delete(key, options)
end
end
end
Defined in actionpack/lib/action_controller/caching/fragments.rb line 95
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Caching::Fragments