Johnny Cache plugin

Plugin details

Allows for a time_to_live option on cached ERB fragments by inserting a timestamp into the HTML.

Websitehttp://offtheline.net/2008/7/10/timestamping-fragment-caches Repositoryhttp://svn.offtheline.net/plugins/johnny_cache/ Author Jason LaPier Tags Cache, ttl LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://svn.offtheline.net/plugins/johnny_cache/

Example
=======

In a view:

  <% cache("some_fragment", :time_to_live => 5.minutes) do -%>
    This fragment was cached at <%= Time.now.utc.strftime "%H:%M:%S on %m/%d/%Y" %> 
    and will expire at: <%= 5.minutes.from_now.utc.strftime "%H:%M:%S on %m/%d/%Y" %> (UTC)
  <% end %>


Checking the cache in a controller:

  # instead of: read_fragment("some_fragment"), try:
  unless get_johnny_cache("some_fragment")
    # make some expensive DB queries
  end


Remember!
=========

If you want to play with caching and you're working in development mode, you need to enable caching.
Find the perform_caching line in environments/development.rb and change it to true:

# config/environments/development.rb
config.action_controller.perform_caching             = true

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 month ago