CacheMetadata
Metadata for the context cache associated with LLM responses.
This stores cache identification, usage tracking, and lifecycle information for a particular cache instance. It can be in one of two states:
Active cache state: cacheName is set and expireTime, invocationsUsed, and createdAt are populated.
Fingerprint-only state: cacheName is
nulland only fingerprint and contentsCount are set, used for prefix matching before a cache exists.
Token counts (cached and total) are available in LlmResponse.usageMetadata and should be accessed from there to avoid duplication.
Constructors
Types
Fluent builder for CacheMetadata, provided primarily for Java callers. Any property left unset falls back to the same default as the constructor.
Properties
Number of contents. When an active cache exists this is the count of cached contents; otherwise it is the count of the cacheable content prefix used for fingerprinting. Must be non-negative.
Whether the cache will expire within EXPIRY_BUFFER. Always false for fingerprint-only metadata (which has no expireTime).
Epoch milliseconds when the cache expires. null when no active cache exists.
Hash of the cacheable contents (system instruction + tools + contents). Always present for prefix matching.
Number of invocations this cache has been used for. null when no active cache exists. Must be non-negative when set.