Class: RubyLLM::SemanticCache::CacheStores::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/semantic_cache/cache_stores/base.rb

Direct Known Subclasses

Memory, Redis

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/ruby_llm/semantic_cache/cache_stores/base.rb', line 7

def initialize(config)
  @config = config
end

Instance Method Details

#clear!Object

Clear all entries

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/ruby_llm/semantic_cache/cache_stores/base.rb', line 33

def clear!
  raise NotImplementedError
end

#delete(id) ⇒ Object

Delete an entry by ID

Parameters:

  • id (String)

    unique identifier

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/ruby_llm/semantic_cache/cache_stores/base.rb', line 28

def delete(id)
  raise NotImplementedError
end

#empty?Boolean

Check if the store is empty

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/ruby_llm/semantic_cache/cache_stores/base.rb', line 38

def empty?
  raise NotImplementedError
end

#get(id) ⇒ Hash?

Get a cached entry by ID

Parameters:

  • id (String)

    unique identifier

Returns:

  • (Hash, nil)

    the cached entry or nil if not found

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/ruby_llm/semantic_cache/cache_stores/base.rb', line 14

def get(id)
  raise NotImplementedError
end

#set(id, data, ttl: nil) ⇒ Object

Store an entry

Parameters:

  • id (String)

    unique identifier

  • data (Hash)

    the data to store

  • ttl (Integer, nil) (defaults to: nil)

    time-to-live in seconds

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/ruby_llm/semantic_cache/cache_stores/base.rb', line 22

def set(id, data, ttl: nil)
  raise NotImplementedError
end

#sizeObject

Get the number of entries stored

Raises:

  • (NotImplementedError)


43
44
45
# File 'lib/ruby_llm/semantic_cache/cache_stores/base.rb', line 43

def size
  raise NotImplementedError
end