CacheEntry

class CacheEntry(val id: String, val scope: String, val prompt: String, val response: String, embedding: FloatArray, val createdAt: Instant, val metadata: Map<String, String> = emptyMap())

One cached prompt/response pair plus the vector used to find it again.

The embedding passed in is normalized on construction, so CacheEntry.embedding is always unit length and Vectors.dot against another normalized vector yields cosine similarity directly.

Identity is the id alone: two entries with the same id are the same entry, whatever else changed. That keeps entries usable as map keys without ever comparing float arrays element by element.

Constructors

Link copied to clipboard
constructor(id: String, scope: String, prompt: String, response: String, embedding: FloatArray, createdAt: Instant, metadata: Map<String, String> = emptyMap())

Properties

Link copied to clipboard

Write time, used for TTL expiry and for reporting the age of a hit.

Link copied to clipboard

Dimensionality of embedding.

Link copied to clipboard

Unit-normalized embedding of prompt.

Link copied to clipboard
val id: String

Store-unique identifier, assigned when the entry is written.

Link copied to clipboard

Free-form caller data, returned untouched on a hit (token counts, model id, trace id...).

Link copied to clipboard

The prompt exactly as it was seen, kept verbatim because the guards re-read it on every hit.

Link copied to clipboard

The response to replay when this entry matches.

Link copied to clipboard

Partition this entry belongs to. Lookups only ever see entries from their own scope, which is how you keep a gpt-4o answer from being served to a haiku caller — see SemanticCache.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Copy of this entry with a different response, keeping id, embedding and creation time. Useful when refreshing a stale answer without paying to re-embed the prompt.