Module: Redis::RedisHashSession
- Included in:
- ActionDispatch::Session::RedisHash, Rack::Session::RedisHash
- Defined in:
- lib/rack/session/redis_hash.rb
Instance Method Summary collapse
- #destroy_session(env, sid, options) ⇒ Object
- #get_session(env, sid) ⇒ Object
- #initialize(app, options = {}) ⇒ Object
- #session_prefix ⇒ Object
- #set_session(env, session_id, session, options) ⇒ Object
Instance Method Details
#destroy_session(env, sid, options) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/rack/session/redis_hash.rb', line 34 def destroy_session(env, sid, ) session = Redis::LazyHash.new( session_prefix => sid ) unless session.nil? [:renew] ? session.renew_key : session.destroy session.key end end |
#get_session(env, sid) ⇒ Object
8 9 10 11 12 |
# File 'lib/rack/session/redis_hash.rb', line 8 def get_session(env, sid) session = Redis::LazyHash.new session_prefix => sid sid = session.key return [sid, session] end |
#initialize(app, options = {}) ⇒ Object
3 4 5 6 |
# File 'lib/rack/session/redis_hash.rb', line 3 def initialize(app, = {}) super @expire_after = [:expire_after] || 60*60 # 60 minutes, default end |
#session_prefix ⇒ Object
42 43 44 |
# File 'lib/rack/session/redis_hash.rb', line 42 def session_prefix :rack_session end |
#set_session(env, session_id, session, options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rack/session/redis_hash.rb', line 14 def set_session(env, session_id, session, ) @expire_after = [:expire_after] || @expire_after unless session.kind_of?(Redis::LazyHash) real_session = Redis::LazyHash.new(session_prefix) real_session.update(session) if session.kind_of?(Hash) real_session.key = session_id unless session_id.nil? session = real_session end if [:drop] session.destroy return false if [:drop] end if [:renew] session_id = session.renew_key end session.save session.expire @expire_after return session_id end |