Module: RedisStore::Rack::Session::Rails

Included in:
ActionController::Session::RedisSessionStore, ActionDispatch::Session::RedisSessionStore
Defined in:
lib/action_controller/session/redis_session_store.rb

Overview

Redis session storage for Rails, and for Rails only. Derived from the MemCacheStore code, simply dropping in Redis instead.

Options: :key => Same as with the other cookie stores, key name :secret => Encryption secret for the key :host => Redis host name, default is localhost :port => Redis port, default is 6379 :db => Database number, defaults to 0. Useful to separate your session storage from other data :key_prefix => Prefix for keys used in Redis, e.g. myapp-. Useful to separate session storage keys visibly from others :expire_after => A number in seconds to set the timeout interval for the session. Will map directly to expiry in Redis

Instance Method Summary collapse

Instance Method Details

#initialize(app, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/action_controller/session/redis_session_store.rb', line 18

def initialize(app, options = {})
  # Support old :expires option
  options[:expire_after] ||= options[:expires]

  super

  servers = [options[:servers]].flatten.compact.map do |server_options|
    {
      :host => 'localhost',
      :port => '6379',
      :db => 0
    }.update(Redis::Factory.convert_to_redis_client_options(server_options))
  end

  @pool = Redis::Factory.create(*servers)
end