pub enum CacheStrategy {
Disabled,
SystemOnly,
MessagesOnly,
Full,
}Expand description
Cache strategy determining which content types to cache.
Anthropic best practices recommend caching static content (system prompts, tools) with longer TTLs and dynamic content (messages) with shorter TTLs.
Variants§
Disabled
No caching - all content sent without cache_control
SystemOnly
Cache system prompt only (static content with long TTL)
MessagesOnly
Cache messages only (last user turn with short TTL)
Full
Cache both system and messages (recommended)
Implementations§
Source§impl CacheStrategy
impl CacheStrategy
Sourcepub fn cache_system(&self) -> bool
pub fn cache_system(&self) -> bool
Returns true if system prompt caching is enabled
Sourcepub fn cache_messages(&self) -> bool
pub fn cache_messages(&self) -> bool
Returns true if message caching is enabled
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true if any caching is enabled
Trait Implementations§
Source§impl Clone for CacheStrategy
impl Clone for CacheStrategy
Source§fn clone(&self) -> CacheStrategy
fn clone(&self) -> CacheStrategy
Returns a duplicate of the value. Read more
1.0.0 · 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 CacheStrategy
impl Debug for CacheStrategy
Source§impl Default for CacheStrategy
impl Default for CacheStrategy
Source§fn default() -> CacheStrategy
fn default() -> CacheStrategy
Returns the “default value” for a type. Read more
Source§impl PartialEq for CacheStrategy
impl PartialEq for CacheStrategy
impl Copy for CacheStrategy
impl Eq for CacheStrategy
impl StructuralPartialEq for CacheStrategy
Auto Trait Implementations§
impl Freeze for CacheStrategy
impl RefUnwindSafe for CacheStrategy
impl Send for CacheStrategy
impl Sync for CacheStrategy
impl Unpin for CacheStrategy
impl UnwindSafe for CacheStrategy
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<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§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.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.