InMemoryEmbeddingCache

org.llm4s.llmconnect.caching.InMemoryEmbeddingCache
See theInMemoryEmbeddingCache companion object
@Stable

Thread-safe in-memory EmbeddingCache with LRU eviction and an optional TTL. Its operations never fail.

Build one with InMemoryEmbeddingCache.create, which checks its arguments.

Value parameters

clock

the clock the TTL is measured with

maxSize

the maximum number of embeddings to store before evicting the least recently used

ttl

how long an entry stays valid; an expired entry is evicted when it is next looked up. An entry exactly ttl old is still valid.

Attributes

Companion
object
Source
InMemoryEmbeddingCache.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def clear(): Result[Unit]

Clears all cached entries and resets the statistics.

Clears all cached entries and resets the statistics.

Attributes

Definition Classes
Source
InMemoryEmbeddingCache.scala
override def get(key: String): Result[Option[Seq[Double]]]

Retrieves an embedding and updates the hit and miss counters.

Retrieves an embedding and updates the hit and miss counters.

Attributes

Definition Classes
Source
InMemoryEmbeddingCache.scala
override def put(key: String, embedding: Seq[Double]): Result[Unit]

Stores an embedding, evicting the least recently used entry when full.

Stores an embedding, evicting the least recently used entry when full.

Attributes

Definition Classes
Source
InMemoryEmbeddingCache.scala
override def stats(): Option[CacheStats]

Always defined: the in-memory cache counts its hits and misses.

Always defined: the in-memory cache counts its hits and misses.

Attributes

Definition Classes
Source
InMemoryEmbeddingCache.scala