pub enum CacheTtlSetting {
Auto,
Fixed(CacheTtl),
}Expand description
The cache_ttl config value: either a fixed CacheTtl or auto.
Auto (default) resolves per credential kind at request time:
- Anthropic OAuth / subscription credentials →
CacheTtl::OneHour(what Claude Code uses on subscriptions; a subscription pays no per-token premium for 1h writes, and idle gaps over five minutes otherwise lose the conversation cache every turn). - Anthropic API key →
CacheTtl::FiveMinutes(1h writes bill at 2× input versus 1.25× for 5m, so API-key users keep the cheaper write). - Other providers ignore
cache_ttlentirely.
Resolution depends only on the credential kind, never on which account or token is in use, so account failover between two subscription seats can never flip the TTL (a TTL change rewrites the cache).
Variants§
Implementations§
Source§impl CacheTtlSetting
impl CacheTtlSetting
Sourcepub fn parse(val: &str) -> Option<CacheTtlSetting>
pub fn parse(val: &str) -> Option<CacheTtlSetting>
auto or any CacheTtl::parse spelling (case-insensitive).
None for unknown values.
Sourcepub fn resolve(self, oauth: bool) -> CacheTtl
pub fn resolve(self, oauth: bool) -> CacheTtl
The wire policy for a request carried on Anthropic credentials of
the given kind (oauth = subscription / OAuth access token, else an
API key). Explicit values always win.
Sourcepub fn resolve_for_auth_type(self, auth_type: &str) -> CacheTtl
pub fn resolve_for_auth_type(self, auth_type: &str) -> CacheTtl
Self::resolve keyed by the runtime’s auth_type string. Only the
exact "oauth" kind counts as a subscription credential.
Trait Implementations§
Source§impl Clone for CacheTtlSetting
impl Clone for CacheTtlSetting
Source§fn clone(&self) -> CacheTtlSetting
fn clone(&self) -> CacheTtlSetting
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 moreimpl Copy for CacheTtlSetting
Source§impl Debug for CacheTtlSetting
impl Debug for CacheTtlSetting
Source§impl Default for CacheTtlSetting
impl Default for CacheTtlSetting
Source§fn default() -> CacheTtlSetting
fn default() -> CacheTtlSetting
Returns the “default value” for a type. Read more
Source§impl Display for CacheTtlSetting
impl Display for CacheTtlSetting
impl Eq for CacheTtlSetting
Source§impl From<CacheTtl> for CacheTtlSetting
impl From<CacheTtl> for CacheTtlSetting
Source§fn from(ttl: CacheTtl) -> CacheTtlSetting
fn from(ttl: CacheTtl) -> CacheTtlSetting
Converts to this type from the input type.
Source§impl PartialEq for CacheTtlSetting
impl PartialEq for CacheTtlSetting
impl StructuralPartialEq for CacheTtlSetting
Auto Trait Implementations§
impl Freeze for CacheTtlSetting
impl RefUnwindSafe for CacheTtlSetting
impl Send for CacheTtlSetting
impl Sync for CacheTtlSetting
impl Unpin for CacheTtlSetting
impl UnsafeUnpin for CacheTtlSetting
impl UnwindSafe for CacheTtlSetting
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.