lib/plezi/handlers/session.rb in plezi-0.10.16 vs lib/plezi/handlers/session.rb in plezi-0.10.17
- old
+ new
@@ -2,10 +2,11 @@
module Base
module SessionStorage
module_function
# returns a session object
def fetch id
+ return Plezi::Session.new(id) if Plezi.redis # avoid a local cache if Redis is used.
@session_cache[id] || (@session_cache[id] = Plezi::Session.new(id))
end
@session_cache = {}
end
end
@@ -18,10 +19,10 @@
# The session's lifetime in seconds = 5 days. This is only true when using the built in support for the Redis persistent storage.
SESSION_LIFETIME = 432_000
# called by the Plezi framework to initiate a session with the id requested
def initialize id
@id = id
- if (conn=Plezi.redis)
+ if id && (conn=Plezi.redis)
@data=conn.hgetall(id)
end
@data ||= {}
end
# Get a key from the session data store. If a Redis server is supplied, it will be used to synchronize session data.