Module: Iodine::Http::SessionManager
- Defined in:
- lib/iodine/http/session.rb
Defined Under Namespace
Modules: FileSessionStorage, MemSessionStorage
Class Method Summary collapse
-
.get(id) ⇒ Object
returns a session object.
-
.storage ⇒ Object
returns the current session storage system.
-
.storage=(session_storage = nil) ⇒ Object
Sets the session storage system, to allow for different storage systems.
Class Method Details
.get(id) ⇒ Object
returns a session object
78 79 80 |
# File 'lib/iodine/http/session.rb', line 78 def get id storage.fetch(id) end |
.storage ⇒ Object
returns the current session storage system.
101 102 103 |
# File 'lib/iodine/http/session.rb', line 101 def storage @storage ||= Iodine::Http::SessionManager::FileSessionStorage end |
.storage=(session_storage = nil) ⇒ Object
Sets the session storage system, to allow for different storage systems.
A Session Storage system must answer only one methods:
- fetch(id)
-
returns a Hash like session object with all the session’s data or a fresh session object if the session object did not exist before
The Session Object should update itself in the storage whenever data is saved to the session Object. This is important also because websocket ‘session’ could exist simultaneously with other HTTP requests and the data should be kept updated at all times. If there are race conditions that apply for multi-threading / multi processing, the Session Object should manage them as well as possible.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/iodine/http/session.rb', line 89 def storage= session_storage = nil case session_storage when :file, nil @storage = Iodine::Http::SessionManager::FileSessionStorage when :mem @storage = Iodine::Http::SessionManager::MemSessionStorage else @storage = session_storage end end |