Infopark's ComponentCache Build Status

Fragment caching with automatic dependency resolution and cache invalidation.

Installation

Add this line to your application's Gemfile:

gem 'infopark_component_cache'

And then execute:

$ bundle

Or install it yourself as:

$ gem install infopark_component_cache

Tests

To run the test suite just execute:

$ bundle exec rspec spec/

No setup neccessary.

Usage

Set up Rails catching (see http://guides.rubyonrails.org/caching_with_rails.html) and in your view write:

<%= cache_tagged_component(@rails_connector_obj, 'any-string-as-component-name', {:additional => :parameters}) do %>
  This content will be cached
<% end %>

and you are done.

Alternatively you could use component cache directly:

<%= InfoparkComponentCache::ComponentCache.new(@rails_connector_obj, 'any-string-as-component-name', {:additional => :parameters}).fetch do %>
  This content will be cached
<% end %>

Most guard also provide an option to limit the lookup to specific object classes, for example:

<%= cache_tagged_component(@gallery, 'gallery', {}, [{guard: InfoparkComponentCache::ObjCount, obj_classes: ['Image']}]) do %>
  This content will be cached
<% end %>

will only get invalidated when the number of objects of the class 'Image' changes in the CMS.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request