Module: Llmemory::ShortTerm::Stores
- Defined in:
- lib/llmemory/short_term/stores.rb,
lib/llmemory/short_term/stores/base.rb,
lib/llmemory/short_term/stores/key_codec.rb,
lib/llmemory/short_term/stores/redis_store.rb,
lib/llmemory/short_term/stores/memory_store.rb,
lib/llmemory/short_term/stores/postgres_store.rb,
lib/llmemory/short_term/stores/active_record_store.rb,
lib/llmemory/short_term/stores/active_record_checkpoint.rb
Defined Under Namespace
Modules: KeyCodec Classes: ActiveRecordCheckpoint, ActiveRecordStore, Base, MemoryStore, PostgresStore, RedisStore
Class Method Summary collapse
-
.build(store_type = nil, cipher: nil) ⇒ Object
Single source of truth for selecting a short-term store backend.
- .reset_shared_singletons! ⇒ Object
- .shared_memory_store(cipher) ⇒ Object
Class Method Details
.build(store_type = nil, cipher: nil) ⇒ Object
Single source of truth for selecting a short-term store backend. Shared by Checkpoint, SessionLifecycle and WorkingMemory.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/llmemory/short_term/stores.rb', line 14 def self.build(store_type = nil, cipher: nil) resolved_cipher = cipher || Llmemory.build_cipher type = (store_type || Llmemory.configuration.short_term_store).to_sym case type when :memory if Llmemory.configuration.shared_memory_stores shared_memory_store(resolved_cipher) else MemoryStore.new(cipher: resolved_cipher) end when :redis then RedisStore.new(cipher: resolved_cipher) when :postgres then PostgresStore.new(cipher: resolved_cipher) when :active_record, :activerecord require_relative "stores/active_record_store" ActiveRecordStore.new(cipher: resolved_cipher) else MemoryStore.new(cipher: resolved_cipher) end end |
.reset_shared_singletons! ⇒ Object
38 39 40 |
# File 'lib/llmemory/short_term/stores.rb', line 38 def self.reset_shared_singletons! @shared_memory_store = nil end |
.shared_memory_store(cipher) ⇒ Object
34 35 36 |
# File 'lib/llmemory/short_term/stores.rb', line 34 def self.shared_memory_store(cipher) @shared_memory_store ||= MemoryStore.new(cipher: cipher) end |