Class: Rubino::Memory::Flusher

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/memory/flusher.rb

Overview

Flushes working memory to persistent storage before compaction. Ensures no important information is lost when context is compressed.

Instance Method Summary collapse

Constructor Details

#initialize(backend: nil) ⇒ Flusher

Returns a new instance of Flusher.



8
9
10
# File 'lib/rubino/memory/flusher.rb', line 8

def initialize(backend: nil)
  @backend = backend
end

Instance Method Details

#flush_before_compaction!(session_id) ⇒ Object

Flushes all pending memories for a session before compaction. Routes through the configured backend’s extract path so compaction mines facts with the same backend the rest of the gem uses.



15
16
17
18
19
20
21
22
# File 'lib/rubino/memory/flusher.rb', line 15

def flush_before_compaction!(session_id)
  extracted = backend.extract(session_id)

  {
    flushed_count: extracted.size,
    session_id: session_id
  }
end