InMemoryEmbeddingCache

org.llm4s.llmconnect.caching.InMemoryEmbeddingCache
class InMemoryEmbeddingCache[Embedding](maxSize: Int) extends EmbeddingCache[Embedding]

Thread-safe in-memory implementation of EmbeddingCache with LRU eviction.

  • @param maxSize The maximum number of embeddings to store before evicting the oldest.

Type parameters

Embedding

The embedding type (usually Seq[Double]).

Attributes

Graph
Supertypes
trait EmbeddingCache[Embedding]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def clear(): Unit

Clears all cached entries and resets statistics.

Clears all cached entries and resets statistics.

Attributes

Definition Classes
def get(key: String): Option[Embedding]

Retrieves an embedding and updates hit/miss counters.

Retrieves an embedding and updates hit/miss counters.

Attributes

def put(key: String, embedding: Embedding): Unit

Stores an embedding, potentially triggering LRU eviction.

Stores an embedding, potentially triggering LRU eviction.

Attributes

override def stats(): CacheStats

Returns type-safe cache statistics.

Returns type-safe cache statistics.

Attributes

Definition Classes