记录类:ContextCacheConfig

java.lang.Object
java.lang.Record
com.google.adk.agents.ContextCacheConfig
Record Components:
cacheIntervals - maximum number of invocations that reuse the same cache before it is refreshed; must be from 1 to 100
ttl - time-to-live of the cache; must be a whole number of seconds, at least one
minTokens - minimum prompt token count of the agent's previous request needed to create a cache; raise it to skip small requests, where cache storage can cost more than it saves; must not be negative
createHttpOptions - HTTP options, such as a timeout, for the call that creates a cache, or null to use the client's defaults; if that call fails, the request is sent without a cache

public record ContextCacheConfig(int cacheIntervals, Duration ttl, int minTokens, @Nullable com.google.genai.types.HttpOptions createHttpOptions) extends Record
为应用程序中的所有代理配置上下文缓存功能。如果没有该功能,任何数据都不会被缓存。
  • 构造函数概述

    Constructors
    Constructor
    Description
    创建一个使用默认值的配置文件: cacheIntervals 在 10 个中, ttl 持续时间为 30 分钟。 minTokens 值为 0,以及客户端的默认 HTTP 设置(client’s default HTTP options)。createHttpOptions 是 null).
    ContextCacheConfig(int cacheIntervals, Duration ttl, int minTokens)
    创建一个配置文件,该配置文件会使用客户端的默认 HTTP 设置来生成缓存。
    ContextCacheConfig(int cacheIntervals, Duration ttl, int minTokens, @Nullable com.google.genai.types.HttpOptions createHttpOptions)
    创建一个配置文件(config.)。
  • 方法概述

    Modifier and Type
    Method
    Description
    int
    返回该值的值。 cacheIntervals “record component”(记录组件)。
    @Nullable com.google.genai.types.HttpOptions
    返回该值的值。 createHttpOptions “record component”(记录组件)。
    final boolean
    用于表示另一个对象是否“等于”当前这个对象。
    返回该资源的 TTL(“Time To Live”,即“生存时间”)。 "<seconds>s" 双子座(Gemini)API所使用的表单格式。
    final int
    返回该对象的哈希码值。
    int
    已弃用(Deprecated)。
    使用 cacheIntervals()这些名称(ADK Python 和 ADK Kotlin)被用于相应的开发工具包中。
    int
    返回该值的值。 minTokens “record component”(记录组件)。
    返回该记录类的字符串表示形式。
    ttl()
    返回该值的值。 ttl “record component”(记录组件)。

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 构造函数详细信息

    • ContextCacheConfig

      public ContextCacheConfig(int cacheIntervals, Duration ttl, int minTokens, @Nullable com.google.genai.types.HttpOptions createHttpOptions)
      创建一个配置文件(config.)。
      Throws:
      IllegalArgumentException - if a value is out of range
    • ContextCacheConfig

      public ContextCacheConfig()
      创建一个使用默认值的配置文件: cacheIntervals 在 10 个中, ttl 持续时间为 30 分钟。 minTokens 值为 0,以及客户端的默认 HTTP 设置(client’s default HTTP options)。createHttpOptions 是 null).
    • ContextCacheConfig

      public ContextCacheConfig(int cacheIntervals, Duration ttl, int minTokens)
      创建一个配置文件,该配置文件会使用客户端的默认 HTTP 设置来生成缓存。
  • 方法详细信息(Method Details)

    • maxInvocations

      @Deprecated @InlineMe(replacement="this.cacheIntervals()") public int maxInvocations()
      Deprecated.
      Use cacheIntervals(), the name ADK Python and ADK Kotlin use.
      返回值 cacheIntervals().
    • getTtlString

      public String getTtlString()
      返回该资源的 TTL(“Time To Live”,即“生存时间”)。 "<seconds>s" 双子座(Gemini)API所使用的表单格式。
    • toString

      public String toString()
      返回该记录类的字符串表示形式。该字符串包含类的名称,以及每个记录组件的名称和对应的值。
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      返回该对象的哈希码值。该哈希码值是由该对象中每个组件的哈希码计算得出的。
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      用于判断另一个对象是否“等于”当前对象。当另一个对象属于相同的类,并且所有记录组件都相同时,这两个对象才被认为是相等的。其中,某些特定的组件(称为“引用组件”)也需要被进行比较。 Objects::equals(Object,Object);原始组件(primitive components)会与……进行比较。 compare 这些方法来自它们对应的包装类(wrapper classes)。
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • cacheIntervals

      public int cacheIntervals()
      返回该值的值。 cacheIntervals “record component”(记录组件)。
      Returns:
      the value of the cacheIntervals record component
    • ttl

      public Duration ttl()
      返回该值的值。 ttl “record component”(记录组件)。
      Returns:
      the value of the ttl record component
    • minTokens

      public int minTokens()
      返回该值的值。 minTokens “record component”(记录组件)。
      Returns:
      the value of the minTokens record component
    • createHttpOptions

      public @Nullable com.google.genai.types.HttpOptions createHttpOptions()
      返回该值的值。 createHttpOptions “record component”(记录组件)。
      Returns:
      the value of the createHttpOptions record component