EmbeddingCache

org.llm4s.llmconnect.caching.EmbeddingCache
@Stable

Storage for the vectors of a CachedEmbeddingClient.

Every operation returns a Result, so a backend that can fail (Redis, a database) reports the failure instead of throwing. CachedEmbeddingClient treats a failed get as a miss and a failed put as not stored, and logs both: the provider still answers. Expiry and eviction are the backend's own concern, set when it is built (InMemoryEmbeddingCache.create takes a maxSize and a ttl).

Attributes

Source
EmbeddingCache.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def clear(): Result[Unit]

Removes every entry.

Removes every entry.

Attributes

Source
EmbeddingCache.scala
def get(key: String): Result[Option[Seq[Double]]]

The vector stored under key, None when there is none (or it has expired), or the backend's error.

The vector stored under key, None when there is none (or it has expired), or the backend's error.

Attributes

Source
EmbeddingCache.scala
def put(key: String, embedding: Seq[Double]): Result[Unit]

Stores embedding under key.

Stores embedding under key.

Attributes

Source
EmbeddingCache.scala

Concrete methods

Hit and miss statistics, for a backend that keeps them; None by default.

Hit and miss statistics, for a backend that keeps them; None by default.

Attributes

Source
EmbeddingCache.scala