Class: Tofu::SessionBar
Instance Method Summary collapse
- #fetch(key) ⇒ Object
-
#initialize ⇒ SessionBar
constructor
A new instance of SessionBar.
- #store(session) ⇒ Object
Constructor Details
#initialize ⇒ SessionBar
Returns a new instance of SessionBar.
84 85 86 87 88 89 |
# File 'lib/tofu.rb', line 84 def initialize super() @pool = {} @keeper = keeper @interval = 60 end |
Instance Method Details
#fetch(key) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/tofu.rb', line 100 def fetch(key) return nil if key.nil? synchronize do session = @pool[key] return nil unless session if session.expired? @pool.delete(key) return nil end return session end end |
#store(session) ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'lib/tofu.rb', line 91 def store(session) key = session.session_id synchronize do @pool[key] = session end @keeper.wakeup return key end |