Class: Phronomy::StateStore::InMemory
- Defined in:
- lib/phronomy/state_store/in_memory.rb
Overview
In-memory state store. Stores state objects keyed by thread_id. State objects are stored directly (no serialization), so this backend is suitable for single-process use only.
Instance Method Summary collapse
- #clear(thread_id) ⇒ self
- #clear_all ⇒ Object
-
#initialize ⇒ InMemory
constructor
A new instance of InMemory.
-
#load(thread_id) ⇒ Object?
State object or nil.
- #save(state) ⇒ self
Constructor Details
#initialize ⇒ InMemory
Returns a new instance of InMemory.
9 10 11 |
# File 'lib/phronomy/state_store/in_memory.rb', line 9 def initialize @store = {} end |
Instance Method Details
#clear(thread_id) ⇒ self
28 29 30 31 |
# File 'lib/phronomy/state_store/in_memory.rb', line 28 def clear(thread_id) @store.delete(thread_id) self end |
#clear_all ⇒ Object
33 34 35 36 |
# File 'lib/phronomy/state_store/in_memory.rb', line 33 def clear_all @store.clear self end |
#load(thread_id) ⇒ Object?
Returns state object or nil.
22 23 24 |
# File 'lib/phronomy/state_store/in_memory.rb', line 22 def load(thread_id) @store[thread_id] end |
#save(state) ⇒ self
15 16 17 18 |
# File 'lib/phronomy/state_store/in_memory.rb', line 15 def save(state) @store[state.thread_id] = state self end |