Class: ActionController::Session::RedisSessionStore

Inherits:
AbstractStore
  • Object
show all
Defined in:
lib/rack/session/rails.rb

Overview

: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

Constructor Details

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

Returns a new instance of RedisSessionStore.



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

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

  super

  @options = { :key_prefix => "" }.update(options)
  servers = [options[:servers]].flatten.compact.map do |server_options|
    {
      :namespace => 'rack:session',
      :host => 'localhost',
      :port => '6379',
      :db => 0
    }.update(RedisFactory.convert_to_redis_client_options(server_options))
  end

  @pool = RedisFactory.create(*servers)
end