pub struct ResponseCachingMiddleware { /* private fields */ }Expand description
Response caching middleware for MCP servers.
Caches responses for list and call operations with configurable TTL. Uses an LRU eviction strategy when the cache is full.
Implementations§
Source§impl ResponseCachingMiddleware
impl ResponseCachingMiddleware
Sourcepub fn max_entries(self, max: usize) -> Self
pub fn max_entries(self, max: usize) -> Self
Sets the maximum number of cache entries.
Sourcepub fn max_size_bytes(self, max: usize) -> Self
pub fn max_size_bytes(self, max: usize) -> Self
Sets the maximum cache size in bytes.
Sourcepub fn max_item_size(self, max: usize) -> Self
pub fn max_item_size(self, max: usize) -> Self
Sets the maximum size per cache item in bytes.
Sourcepub fn list_ttl_secs(self, secs: u64) -> Self
pub fn list_ttl_secs(self, secs: u64) -> Self
Sets the TTL for list operations (tools/list, resources/list, prompts/list).
Sourcepub fn call_ttl_secs(self, secs: u64) -> Self
pub fn call_ttl_secs(self, secs: u64) -> Self
Sets the TTL for call/get/read operations.
Sourcepub fn disable_tools_list(self) -> Self
pub fn disable_tools_list(self) -> Self
Disables caching for tools/list.
Sourcepub fn disable_resources_list(self) -> Self
pub fn disable_resources_list(self) -> Self
Disables caching for resources/list.
Sourcepub fn disable_prompts_list(self) -> Self
pub fn disable_prompts_list(self) -> Self
Disables caching for prompts/list.
Sourcepub fn disable_tools_call(self) -> Self
pub fn disable_tools_call(self) -> Self
Disables caching for tools/call.
Sourcepub fn disable_resources_read(self) -> Self
pub fn disable_resources_read(self) -> Self
Disables caching for resources/read.
Sourcepub fn disable_prompts_get(self) -> Self
pub fn disable_prompts_get(self) -> Self
Disables caching for prompts/get.
Sourcepub fn include_tools(self, tools: Vec<String>) -> Self
pub fn include_tools(self, tools: Vec<String>) -> Self
Sets the list of tools to include in caching (empty = all).
Sourcepub fn exclude_tools(self, tools: Vec<String>) -> Self
pub fn exclude_tools(self, tools: Vec<String>) -> Self
Sets the list of tools to exclude from caching.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Returns current cache statistics.
Sourcepub fn invalidate(&self, method: &str, params: Option<&Value>)
pub fn invalidate(&self, method: &str, params: Option<&Value>)
Invalidates a specific cache entry by method and params.