Class: ActionDispatch::Session::RedisSessionStore
- Inherits:
-
AbstractStore
- Object
- AbstractStore
- ActionDispatch::Session::RedisSessionStore
- 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
-
#initialize(app, options = {}) ⇒ RedisSessionStore
constructor
A new instance of RedisSessionStore.
Constructor Details
#initialize(app, options = {}) ⇒ RedisSessionStore
Returns a new instance of RedisSessionStore.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/redis-session-store.rb', line 20 def initialize(app, = {}) # Support old :expires option [:expire_after] ||= [:expires] super @default_options = { :namespace => 'rack:session', :host => 'localhost', :port => '6379', :db => 0, :key_prefix => "" }.update() @pool = Redis.new(@default_options) end |