Class: Terret::Store::Memory

Inherits:
Hames::Service
  • Object
show all
Defined in:
lib/terret/store.rb

Overview

In-memory provider: the test default. Events are immutable, so sharing objects with Sessions' working set costs nothing.

Instance Method Summary collapse

Instance Method Details

#append(event) ⇒ Object



24
# File 'lib/terret/store.rb', line 24

def append(event) = @events[event.session_id] << event

#read(session_id, from_seq: 0) ⇒ Object



26
27
28
# File 'lib/terret/store.rb', line 26

def read(session_id, from_seq: 0)
  @events.fetch(session_id, []).select { |ev| ev.seq >= from_seq }
end

#session_idsObject

Order is provider-defined; recency must be derived from event timestamps.



31
# File 'lib/terret/store.rb', line 31

def session_ids = @events.keys

#start(_ctx) ⇒ Object



20
21
22
# File 'lib/terret/store.rb', line 20

def start(_ctx)
  @events ||= Hash.new { |h, k| h[k] = [] }
end