#[non_exhaustive]pub struct ClientCacheConfig {
pub enabled: bool,
pub default_ttl: Duration,
pub max_ttl: Duration,
pub private_partition: Option<String>,
pub max_entries: usize,
pub serve_stale_on_error: bool,
}client and (crate features client or server) only.Expand description
Configuration for the built-in MCP client response cache.
A cache is allocated per client Peer. Public responses may be reused
throughout that client connection. Private responses are additionally
partitioned by private_partition; changing the partition drops every
private entry while preserving public entries.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.enabled: boolEnables cache reads and writes.
default_ttl: DurationTTL used when a backwards-compatible server omits ttlMs.
The default is zero, which leaves such responses immediately stale.
max_ttl: DurationUpper bound applied to both server-provided and default TTLs.
private_partition: Option<String>Stable opaque identity for the current authorization context.
A single-principal client may leave this unset because each client owns its own in-memory store. Gateways or clients that change principals on an existing connection should set this value and update it whenever the authorization context changes.
max_entries: usizeMaximum number of responses retained by the in-memory cache.
A value of zero disables the size limit.
serve_stale_on_error: boolServes an expired cached response when a re-fetch fails.
SEP-2549 permits clients to serve stale responses if errors occur while re-fetching (for example, network issues or server downtime). When this is enabled the client retains expired entries so it can fall back to the last known response instead of surfacing the transport or server error. A successful re-fetch always overwrites the stale entry.
Implementations§
Source§impl ClientCacheConfig
impl ClientCacheConfig
Sourcepub fn with_default_ttl(self, default_ttl: Duration) -> Self
pub fn with_default_ttl(self, default_ttl: Duration) -> Self
Sets the TTL used when a response omits ttlMs.
Sourcepub fn with_max_ttl(self, max_ttl: Duration) -> Self
pub fn with_max_ttl(self, max_ttl: Duration) -> Self
Sets the maximum TTL the client will honour.
Sourcepub fn with_private_partition(self, partition: impl Into<String>) -> Self
pub fn with_private_partition(self, partition: impl Into<String>) -> Self
Sets the stable partition for private responses.
Sourcepub fn with_max_entries(self, max_entries: usize) -> Self
pub fn with_max_entries(self, max_entries: usize) -> Self
Sets the maximum number of retained responses.
Sourcepub fn with_serve_stale_on_error(self, serve_stale_on_error: bool) -> Self
pub fn with_serve_stale_on_error(self, serve_stale_on_error: bool) -> Self
Controls whether an expired response may be served when a re-fetch fails.
Trait Implementations§
Source§impl Clone for ClientCacheConfig
impl Clone for ClientCacheConfig
Source§fn clone(&self) -> ClientCacheConfig
fn clone(&self) -> ClientCacheConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClientCacheConfig
impl Debug for ClientCacheConfig
Source§impl Default for ClientCacheConfig
impl Default for ClientCacheConfig
impl Eq for ClientCacheConfig
Source§impl PartialEq for ClientCacheConfig
impl PartialEq for ClientCacheConfig
impl StructuralPartialEq for ClientCacheConfig
Auto Trait Implementations§
impl Freeze for ClientCacheConfig
impl RefUnwindSafe for ClientCacheConfig
impl Send for ClientCacheConfig
impl Sync for ClientCacheConfig
impl Unpin for ClientCacheConfig
impl UnsafeUnpin for ClientCacheConfig
impl UnwindSafe for ClientCacheConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.