Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Reduce cache requests by preheating via multi_get

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 Rakefile
Octocat-spinner-32 Readme.md
Octocat-spinner-32 VERSION
Octocat-spinner-32 init.rb
Octocat-spinner-32 preheatable_cache.gemspec
Readme.md

Reduce cache requests by preheating via multi_get.

Makes Rails MemCacheStore preheatable via read_multi, for keys that will later be used.
Clears the preheated cache after each request.

  • not threadsave
  • not altered when writing/incrementing/... underlying cache store

Install

gem install preheatable_cache

OR script/plugin install http://github.com/grosser/preheatable_cache

Usage

# controller - multi_get to fetch all keys at once
Rails.cache.preheat @products.map{|p| "views/product_#{p.id}" }

# view - no requests to the cache server
<% cache "product_#{product.id}" do %>
  ...
<% end %>

Author

Michael Grosser
grosser.michael@gmail.com
Hereby placed under public domain, do what you want, just do not hold me accountable...

Something went wrong with that request. Please try again.