Redis stores for Rack::Cache

Build Status Gem Version Build Status Code Climate

redis-rack-cache provides a Redis backed store for Rack::Cache, an HTTP cache. See the main redis-store readme for general guidelines.

NOTE: This gem is necessary in addition to redis-rails if you use Redis to store the Rails cache. redis-rails does not pull in this gem by default since not all applications use Rack::Cache as their HTTP cache.


# Gemfile
gem 'redis-rack-cache'


In a Rails app, you can configure your Rack::Cache stores like this:

# config/environments/production.rb
Rails.application.configure do
  config.action_dispatch.rack_cache = {
    metastore: "#{Rails.credentials.redis_url}/1/rack_cache_metastore",
    entitystore: "#{Rails.credentials.redis_url}/1/rack_cache_entitystore"
    # NOTE: `:meta_store` and `:entity_store` are also supported.

For more complicated setups, like when using custom options, the following syntax can also be used:

# config/environments/production.rb
Rails.application.configure do
  config.action_dispatch.rack_cache = {
    meta_store:"#{Rails.credentials.redis_url}/1/rack_cache_metastore", default_ttl: 10.days.to_i),
    entity_store:"#{Rails.credentials.redis_url}/1/rack_cache_entitystore", default_ttl: 120.days.to_i)
    # NOTE: `:metastore` and `:entitystore` are also supported.

For standalone usage (in non-Rails apps):

require 'rack'
require 'rack/cache'
require 'redis-rack-cache'

use Rack::Cache,
  metastore: 'redis://localhost:6379/0/metastore',
  entitystore: 'redis://localhost:6380/0/entitystore'


First, get the project set up on your local machine:

git clone
cd redis-rack-cache
bundle install

You can run the following command to execute the test suite:

bundle exec rake test

If you are on Snow Leopard you have to run env ARCHFLAGS="-arch x86_64" bundle exec rake


2009 - 2013 Luca Guidi -, released under the MIT license