Sha256: b24d8a7660788f2ba680ee71efc575bddaa399897b98af513e0ae388812f57d2

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 KB

Contents

# Infopark's ComponentCache [![Build Status](https://travis-ci.com/infopark/component_cache.svg?token=9yf7x57D3eQF9WPTdzqX&branch=master)](https://travis-ci.com/infopark/component_cache)

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](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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
infopark_component_cache-5.0.2 README.md
infopark_component_cache-5.0.1 README.md
infopark_component_cache-4.2.0 README.md
infopark_component_cache-4.1.0 README.md