Module: Iodine::Http::SessionManager
- Defined in:
- lib/iodine/http/session.rb
Overview
session management for Iodine’s Http Server
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
79 80 81 |
# File 'lib/iodine/http/session.rb', line 79 def get id storage.fetch(id) end |
.storage ⇒ Object
returns the current session storage system.
102 103 104 |
# File 'lib/iodine/http/session.rb', line 102 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.
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/iodine/http/session.rb', line 90 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 |