Class: RedisSessionStore

Inherits:
ActionController::Session::AbstractStore
  • Object
show all
Defined in:
lib/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

Constructor Details

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

Returns a new instance of RedisSessionStore.



17
18
19
20
21
22
23
24
25
# File 'lib/redis-session-store.rb', line 17

def initialize(app, options = {})
  super

  redis_options = {}
  @default_options.merge!(:namespace => 'rack:session')
  @default_options.merge!(options[:redis]) if options[:redis]

  @redis = Redis.new(redis_options)
end