diff options
author | José Valim <jose.valim@gmail.com> | 2008-05-16 19:10:30 +0200 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-05-19 10:38:59 +0100 |
commit | 99860b72aebe0348f41e82d4710343498d89a84b (patch) | |
tree | 56457862ab6ce523cfb7d6dacd9f38655ab8c715 /actionpack/lib | |
parent | 17d1319c480e58e28641b243da50ae5e5eab89dc (diff) | |
download | rails-99860b72aebe0348f41e82d4710343498d89a84b.tar.gz rails-99860b72aebe0348f41e82d4710343498d89a84b.tar.bz2 rails-99860b72aebe0348f41e82d4710343498d89a84b.zip |
Add fragment_exist? and exist? methods to cache stores. [#203 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/caching/fragments.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/caching/fragments.rb b/actionpack/lib/action_controller/caching/fragments.rb index e4d8678a07..e4f5de44ab 100644 --- a/actionpack/lib/action_controller/caching/fragments.rb +++ b/actionpack/lib/action_controller/caching/fragments.rb @@ -98,6 +98,17 @@ module ActionController #:nodoc: end end + # Check if a cached fragment from the location signified by <tt>key</tt> exists (see <tt>expire_fragment</tt> for acceptable formats) + def fragment_exist?(key, options = nil) + return unless cache_configured? + + key = fragment_cache_key(key) + + self.class.benchmark "Cached fragment exists?: #{key}" do + cache_store.exist?(key, options) + end + end + # 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 } @@ -124,4 +135,4 @@ module ActionController #:nodoc: end end end -end
\ No newline at end of file +end |