Class: MixinBot::SessionStore
- Inherits:
-
Object
- Object
- MixinBot::SessionStore
- Defined in:
- lib/mixin_bot/session_store.rb
Overview
In-memory cache of recipient sessions for encrypted-message sending.
Mirrors the Go SDK's MapSessionStore: fetch returns the cached session
list for a recipient user (or nil on a miss) and store overwrites it;
storing nil evicts the entry (used when sessions expire mid-send).
Any object answering both calls can be passed as session_store: to
API#post_encrypted_messages to plug in custom caching (e.g. Redis, TTLs).
Instance Method Summary collapse
- #fetch(user_id) ⇒ Object
-
#initialize ⇒ SessionStore
constructor
A new instance of SessionStore.
- #store(user_id, sessions) ⇒ Object
Constructor Details
#initialize ⇒ SessionStore
Returns a new instance of SessionStore.
14 15 16 |
# File 'lib/mixin_bot/session_store.rb', line 14 def initialize @sessions = {} end |
Instance Method Details
#fetch(user_id) ⇒ Object
18 19 20 |
# File 'lib/mixin_bot/session_store.rb', line 18 def fetch(user_id) @sessions[user_id] end |
#store(user_id, sessions) ⇒ Object
22 23 24 |
# File 'lib/mixin_bot/session_store.rb', line 22 def store(user_id, sessions) @sessions[user_id] = sessions end |