Rcache
Caches activerecord query results to memory and redis
Installation
Add this line to your application's Gemfile:
gem 'rcache'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rcache
In your initializers:
Rcache.configure do |config|
config.redis = <your connect to redis>
end
Optional settings:
- expires_in (default 60)
- log_cached_queries (default true)
- key_prefix (default rcache::)
Usage
Cache find result for 60 seconds:
Client.rcache.find(2)
Cache count results:
Client.rcache.count
Cache where results with includes for 10 seconds and not show cached queries in log:
Event.limit(2).includes(:thumbnails, :type => :variable).rcache(:expires_in => 10.seconds, :log_cached_queries => false)
It supports only activerecord 3.2 so far
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request