Redis stores for Rack::Cache
Clone or download
tubbo Merge pull request #24 from yasyf/master
Allow for TLS redis connections
Latest commit 3b1be91 Oct 9, 2018

README.md

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.

Installation

# Gemfile
gem 'redis-rack-cache'

Usage

If you are using redis-store with Rails, consider using the redis-rails gem instead.

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

# config/application.rb
module MyApplication
  class Application < Rails::Application
    config.action_dispatch.rack_cache = {
      metastore: ::Rack::Cache::EntityStore::Redis.new('redis://localhost:6379/0/metastore', default_ttl: 10.days.to_i),
      entity_store: ::Rack::Cache::MetaStore::Redis.new('redis://localhost:6380/0/entitystore', default_ttl: 120.days.to_i)
    }
  end
end

For standalone usage (in non-Rails apps):

# config.ru
require 'rack'
require 'rack/cache'
require 'redis-rack-cache'

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

Development

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

git clone https://github.com/redis-store/redis-rack-cache.git
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

Copyright

2009 - 2013 Luca Guidi - http://lucaguidi.com, released under the MIT license