ContextCacheConfig class

Context-cache policy settings for an agent/app.

Unless an agent provides a pre-created cache via LlmAgent.generateContentConfig.cachedContent, caching begins on the second turn of a session at the earliest and requires the cacheable prefix to reach the model-specific minimum: 2048 tokens for Gemini 2.5 or 4096 tokens for Gemini 3. Short or single-turn sessions are therefore only cached when seeded via cachedContent. This config has no effect on a model that does not support explicit context caching, such as Gemini 4: its requests are sent without an explicit cache.

Constructors

ContextCacheConfig({int cacheIntervals = 10, int ttlSeconds = 1800, int minTokens = 0})
Creates a context cache config.
ContextCacheConfig.fromJson(Map<String, Object?> json)
Creates cache config from JSON.
factory

Properties

cacheIntervals → int
Interval count used before cache updates.
final
hashCode → int
The hash code for this object.
no setterinherited
minTokens → int
Minimum token threshold to enable caching.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
ttlSeconds → int
Cache TTL in seconds.
final
ttlString → String
TTL string representation for backend APIs.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, Object?>
Serializes cache config to JSON.
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited