缓存元数据

data class CacheMetadata(val fingerprint: String, val contentsCount: Int, val cacheName: String? = null, val expireTime: Long? = null, val invocationsUsed: Int? = null, val createdAt: Long? = null)

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:

  1. Active cache state: cacheName is set and expireTime, invocationsUsed, and createdAt are populated.

  2. Fingerprint-only state: cacheName is null and 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)

Link copied to clipboard
constructor(fingerprint: String, contentsCount: Int, cacheName: String? = null, expireTime: Long? = null, invocationsUsed: Int? = null, createdAt: Long? = null)

类型

Link copied to clipboard
class Builder

Fluent Builder for CacheMetadata该功能主要为 Java 语言的调用者提供支持;如果某个属性未被设置,其值将默认使用构造函数中指定的默认值。

Link copied to clipboard
object Companion

属性(Properties)

Link copied to clipboard

缓存内容的完整资源名称(例如: projects/123/locations/us-central1/cachedContents/456). null 当没有活动的缓存存在时。

Link copied to clipboard

内容数量:当存在有效的缓存时,该数值表示已缓存的内容数量;否则,该数值表示用于内容识别的可缓存内容前缀的数量。该数值必须为非负数。

Link copied to clipboard

缓存创建时的时间(以毫秒为单位)。 null 当没有活动的缓存存在时,系统会读取 ADK Python 提供的“小数秒级时间戳”(即以秒为单位的精确时间值)。

Link copied to clipboard

缓存是否会在指定的时间内过期? EXPIRY_BUFFER. 总是 false 对于仅包含指纹信息的元数据(这类元数据不包含其他任何内容),…… expireTime).

Link copied to clipboard

缓存失效的时间(以毫秒为单位)。 null 当没有活动的缓存存在时,系统会读取 ADK Python 提供的“小数秒级时间戳”(即以秒为单位的精确时间值)。

Link copied to clipboard

可缓存内容的哈希值(系统指令 + 工具 + 内容)。该哈希值始终存在,用于前缀匹配(prefix matching)。

Link copied to clipboard

该缓存被调用的次数。 null 当不存在任何有效的缓存时(即没有正在使用的缓存数据时),该值必须被设置为非负数。

Link copied to clipboard

这些元数据是用来表示一个处于“活动状态”的缓存(即缓存中的数据仍在被使用中),还是仅仅表示一个“仅包含缓存指纹”的状态(即缓存中的数据已经被标记为不再需要更新)。

函数

Link copied to clipboard

返回一个 Builder 使用该实例的属性进行初始化,主要适用于 Java 调用者。建议优先选择这种方式。 copy 来自 Java 的代码: copy 该函数会按位置获取所有属性的值;因此,每当有新属性被添加时,其函数签名(即函数的定义)就会发生变化。

Link copied to clipboard
open override fun toString(): String