pub struct CacheConfig {
pub enabled: bool,
pub ttl: Option<CacheTtl>,
pub max_breakpoints: Option<u8>,
}Expand description
Caller-facing control over provider-side prompt caching.
This is additive: a ChatRequest with cache = None preserves each
provider’s default caching behaviour. Set it to shape (or disable) caching:
enabled = falseopts the request out of caching entirely — providers send nocache_controlbreakpoints.ttlselects the cache retention window (Anthropic ephemeral TTL).max_breakpointscaps how many cache breakpoints the provider may emit, in decreasing order of prefix stability (tools, then system, then the conversation tail).Noneleaves the provider’s default count.
Providers without a prompt-cache control ignore every field gracefully.
Fields§
§enabled: boolWhether prompt caching is enabled for this request.
ttl: Option<CacheTtl>Optional cache retention window. None uses the provider default.
max_breakpoints: Option<u8>Optional cap on the number of cache breakpoints the provider emits.
Implementations§
Source§impl CacheConfig
impl CacheConfig
Sourcepub const fn enabled() -> CacheConfig
pub const fn enabled() -> CacheConfig
An enabled cache config with provider defaults (no TTL override, all breakpoints).
Sourcepub const fn disabled() -> CacheConfig
pub const fn disabled() -> CacheConfig
A config that opts the request out of provider-side caching.
Sourcepub const fn with_ttl(self, ttl: CacheTtl) -> CacheConfig
pub const fn with_ttl(self, ttl: CacheTtl) -> CacheConfig
Set the cache retention window.
Sourcepub const fn with_max_breakpoints(self, max_breakpoints: u8) -> CacheConfig
pub const fn with_max_breakpoints(self, max_breakpoints: u8) -> CacheConfig
Cap the number of cache breakpoints the provider may emit.
Trait Implementations§
Source§impl Clone for CacheConfig
impl Clone for CacheConfig
Source§fn clone(&self) -> CacheConfig
fn clone(&self) -> CacheConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CacheConfig
impl Debug for CacheConfig
Source§impl Default for CacheConfig
impl Default for CacheConfig
Source§fn default() -> CacheConfig
fn default() -> CacheConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CacheConfig
impl RefUnwindSafe for CacheConfig
impl Send for CacheConfig
impl Sync for CacheConfig
impl Unpin for CacheConfig
impl UnsafeUnpin for CacheConfig
impl UnwindSafe for CacheConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more