Record Class ContextCacheConfig
java.lang.Object
java.lang.Record
com.google.adk.agents.ContextCacheConfig
- Record Components:
maxInvocations- Maximum number of invocations to reuse the same cache before refreshing it. Defaults to 10.ttl- Time-to-live for cache. Defaults to 1800 seconds (30 minutes).minTokens- Minimum estimated request tokens required to enable caching. This compares against the estimated total tokens of the request (system instruction + tools + contents). Context cache storage may have cost. Set higher to avoid caching small requests where overhead may exceed benefits. Defaults to 0.
Configuration for context caching across all agents in an app.
This configuration enables and controls context caching behavior for all LLM agents in an app. When this config is present on an app, context caching is enabled for all agents. When absent (null), context caching is disabled.
Context caching can significantly reduce costs and improve response times by reusing previously processed context across multiple requests.
-
Constructor Summary
ConstructorsConstructorDescriptionContextCacheConfig(int maxInvocations, Duration ttl, int minTokens) Creates an instance of aContextCacheConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns TTL as string format for cache creation.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxInvocationsrecord component.intReturns the value of theminTokensrecord component.toString()Returns a string representation of this record class.ttl()Returns the value of thettlrecord component.
-
Constructor Details
-
ContextCacheConfig
public ContextCacheConfig() -
ContextCacheConfig
Creates an instance of aContextCacheConfigrecord class.- Parameters:
maxInvocations- the value for themaxInvocationsrecord componentttl- the value for thettlrecord componentminTokens- the value for theminTokensrecord component
-
-
Method Details
-
getTtlString
Returns TTL as string format for cache creation. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
maxInvocations
public int maxInvocations()Returns the value of themaxInvocationsrecord component.- Returns:
- the value of the
maxInvocationsrecord component
-
ttl
-
minTokens
-