Module: Ollama::Documents::Cache::Common

Included in:
MemoryCache, RedisCache
Defined in:
lib/ollama/documents/cache/common.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#prefix=(value) ⇒ Object (writeonly)

Sets the attribute prefix

Parameters:

  • value

    the value to set the attribute prefix to.



2
3
4
# File 'lib/ollama/documents/cache/common.rb', line 2

def prefix=(value)
  @prefix = value
end

Instance Method Details

#collections(prefix) ⇒ Object



4
5
6
7
8
# File 'lib/ollama/documents/cache/common.rb', line 4

def collections(prefix)
  unique = Set.new
  full_each { |key, _| unique << key[/\A#{prefix}(.*)-/, 1] }
  unique.map(&:to_sym)
end

#pre(key) ⇒ Object



10
11
12
# File 'lib/ollama/documents/cache/common.rb', line 10

def pre(key)
  [ @prefix, key ].join
end

#unpre(key) ⇒ Object



14
15
16
# File 'lib/ollama/documents/cache/common.rb', line 14

def unpre(key)
  key.sub(/\A#@prefix/, '')
end