Module: OllamaChat::DocumentCache

Included in:
Chat
Defined in:
lib/ollama_chat/document_cache.rb

Instance Method Summary collapse

Instance Method Details

#configure_cacheClass

The configure_cache method determines the appropriate cache class to use for document storage. It checks if the -M option was specified to use MemoryCache, otherwise it attempts to use the configured cache class. If an error occurs during this process, it falls back to using MemoryCache and reports the error.

Returns:

  • (Class)

    the selected cache class to be used for document caching



18
19
20
21
22
23
24
25
26
27
# File 'lib/ollama_chat/document_cache.rb', line 18

def configure_cache
  if @opts[?M]
    Documentrix::Documents::MemoryCache
  else
    document_cache_class
  end
rescue => e
  STDERR.puts "Caught #{e.class}: #{e} => Falling back to MemoryCache."
  Documentrix::Documents::MemoryCache
end

#document_cache_classClass

The document_cache_class method returns the cache class specified in the configuration.

Returns:

  • (Class)

    the cache class defined by the config.cache setting



6
7
8
# File 'lib/ollama_chat/document_cache.rb', line 6

def document_cache_class
  Object.const_get(config.cache)
end