Method: Merb::Cache::ControllerInstanceMethods#cached_page?

Defined in:
lib/merb-cache/cache-page.rb

#cached_page?(options) ⇒ Boolean

Checks whether a cache entry exists

Parameter

options<String,Hash>

The options that will be passed to #key_for

Returns

true if the cache entry exists, false otherwise

Example

cached_page?(:action => 'show', :params => [params[:page]])
cached_page?(:action => 'show', :extension => 'js')

Returns:

  • (Boolean)


60
61
62
63
64
# File 'lib/merb-cache/cache-page.rb', line 60

def cached_page?(options)
  key = Merb::Controller._cache.key_for(options, controller_name, true)
  extension = options[:extension] || DEFAULT_PAGE_EXTENSION
  File.file?(Merb::Controller._cache.config[:cache_html_directory] / "#{key}.#{extension}")
end