README.md in redis-rails-5.0.1 vs README.md in redis-rails-5.0.2.pre

- old
+ new

@@ -2,50 +2,65 @@ __`redis-rails`__ provides a full set of stores (*Cache*, *Session*, *HTTP Cache*) for __Ruby on Rails__. See the main [redis-store readme](https://github.com/redis-store/redis-store) for general guidelines. ## Installation +Add the following to your Gemfile: + ```ruby -# Gemfile -gem "redis-rails" # Will install several other redis-* gems +gem 'redis-rails' ``` +To use with Rails 4.0+, pin the gem to the latest 4.0 version: + +```ruby +gem 'redis-rails', '~> 4' +``` + ## Usage ```ruby # config/application.rb config.cache_store = :redis_store, "redis://localhost:6379/0/cache", { expires_in: 90.minutes } ``` +(**NOTE:** The `:expires_in` option can also be written as `:expire_in` and `:expire_after`) + Configuration values at the end are optional. If you want to use Redis as a backend for sessions, you will also need to set: ```ruby # config/initializers/session_store.rb -MyApplication::Application.config.session_store :redis_store, servers: "redis://localhost:6379/0/session" +MyApplication::Application.config.session_store :redis_store, servers: ["redis://localhost:6379/0/session"] ``` You can also provide a hash instead of a URL ```ruby -config.cache_store = :redis_store, { host: "localhost", - port: 6379, - db: 0, - password: "mysecret", - namespace: "cache", - expires_in: 90.minutes } +config.cache_store = :redis_store, { + host: "localhost", + port: 6379, + db: 0, + password: "mysecret", + namespace: "cache" +} ``` And similarly for the session store: ```ruby -MyApplication::Application.config.session_store :redis_store, servers: { host: "localhost", - port: 6379, - db: 0, - password: "mysecret", - namespace: "session" - }, - expires_in: 90.minutes +MyApplication::Application.config.session_store :redis_store, { + servers: [ + { + host: "localhost", + port: 6379, + db: 0, + password: "mysecret", + namespace: "session" + }, + ], + expire_after: 90.minutes +} ``` And if you would like to use Redis as a rack-cache backend for HTTP caching, add [`redis-rack-cache`](https://github.com/redis-store/redis-rack-cache) to your Gemfile and add: ```ruby @@ -81,31 +96,35 @@ ) # configure sessions, setting the sentinel config as the # servers value, merging opts with the sentinel conf. config.session_store :redis_store, { - servers: sentinel_config.merge( - namespace: "sessions" - ), + servers: [ + sentinel_config.merge( + namespace: "sessions" + ) + ], expires_in: 2.days } ``` ## Running tests ```shell gem install bundler git clone git://github.com/redis-store/redis-rails.git cd redis-rails -bundle install -bundle exec rake +RAILS_VERSION=5.0.1 bundle install +RAILS_VERSION=5.0.1 bundle exec rake ``` If you are on **Snow Leopard** you have to run `env ARCHFLAGS="-arch x86_64" bundle exec rake` ## Status -[![Gem Version](https://badge.fury.io/rb/redis-rails.png)](http://badge.fury.io/rb/redis-rails) [![Build Status](https://secure.travis-ci.org/redis-store/redis-rails.png?branch=master)](http://travis-ci.org/jodosha/redis-rails?branch=master) [![Code Climate](https://codeclimate.com/github/jodosha/redis-store.png)](https://codeclimate.com/github/redis-store/redis-rails) +[![Gem Version](https://badge.fury.io/rb/redis-rails.png)](http://badge.fury.io/rb/redis-rails) +[![Build Status](https://secure.travis-ci.org/redis-store/redis-rails.png?branch=master)](http://travis-ci.org/redis-store/redis-rails?branch=master) +[![Code Climate](https://codeclimate.com/github/redis-store/redis-rails.png)](https://codeclimate.com/github/redis-store/redis-rails) ## Copyright 2009 - 2011 Luca Guidi - [http://lucaguidi.com](http://lucaguidi.com), released under the MIT license