Class: Llmemory::ShortTerm::Stores::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/llmemory/short_term/stores/base.rb

Instance Method Summary collapse

Instance Method Details

#delete(user_id, session_id) ⇒ Object

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/llmemory/short_term/stores/base.rb', line 15

def delete(user_id, session_id)
  raise NotImplementedError, "#{self.class}#delete must be implemented"
end

#list_sessions(user_id:) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/llmemory/short_term/stores/base.rb', line 32

def list_sessions(user_id:)
  raise NotImplementedError, "#{self.class}#list_sessions must be implemented"
end

#list_usersObject

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/llmemory/short_term/stores/base.rb', line 28

def list_users
  raise NotImplementedError, "#{self.class}#list_users must be implemented"
end

#load(user_id, session_id) ⇒ Object

Raises:

  • (NotImplementedError)


11
12
13
# File 'lib/llmemory/short_term/stores/base.rb', line 11

def load(user_id, session_id)
  raise NotImplementedError, "#{self.class}#load must be implemented"
end

#save(user_id, session_id, state) ⇒ Object

Raises:

  • (NotImplementedError)


7
8
9
# File 'lib/llmemory/short_term/stores/base.rb', line 7

def save(user_id, session_id, state)
  raise NotImplementedError, "#{self.class}#save must be implemented"
end

#update(user_id, session_id) ⇒ Object

Atomic read-modify-write. Yields the current state (may be nil) and persists the block's return value when non-nil.



21
22
23
24
25
26
# File 'lib/llmemory/short_term/stores/base.rb', line 21

def update(user_id, session_id)
  current = load(user_id, session_id)
  new_state = yield(current)
  save(user_id, session_id, new_state) unless new_state.nil?
  new_state
end