RailsCacheIt

Help you cache with ActiveRecord.

Only support Rails program.

Installation

Add this line to your application's Gemfile:

gem 'rails_cache_it'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_cache_it

Usage

cache

User.limit(50).cache_it

Only work on Relation now(it means you can't use it with #first #last etc..).

expires

User.limit(50).cache_it{ User.count}

when block.call != pre_block.call cache will expires

allowed options

view AvtiveSupport::Cache::Store#fetch

set default options

RailsCacheIt.default_options.merge(options)

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