Last Updated: February 25, 2016
·
8.773K
· revskill

Use Redis as Cache store for Rails

1. In Gemfile:

gem "redis-store"
gem 'redis-rails'
gem "redis-rack-cache"

2. In config/environments/production.rb:

config.cache_store = :redis_store, 'redis://localhost:6379/1'
config.action_dispatch.rack_cache = {
    metastore:   "redis://localhost:6379/1/metastore",
    entitystore: "redis://localhost:6379/1/entitystore"
}

3. In Config.ru:

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

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