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 new() -> ResponseCachingMiddleware
pub fn new() -> ResponseCachingMiddleware
Creates a new response caching middleware with default settings.
Sourcepub fn max_entries(self, max: usize) -> ResponseCachingMiddleware
pub fn max_entries(self, max: usize) -> ResponseCachingMiddleware
Sets the maximum number of cache entries.
Sourcepub fn max_size_bytes(self, max: usize) -> ResponseCachingMiddleware
pub fn max_size_bytes(self, max: usize) -> ResponseCachingMiddleware
Sets the maximum cache size in bytes.
Sourcepub fn max_item_size(self, max: usize) -> ResponseCachingMiddleware
pub fn max_item_size(self, max: usize) -> ResponseCachingMiddleware
Sets the maximum size per cache item in bytes.
Sourcepub fn list_ttl_secs(self, secs: u64) -> ResponseCachingMiddleware
pub fn list_ttl_secs(self, secs: u64) -> ResponseCachingMiddleware
Sets the TTL for list operations (tools/list, resources/list, prompts/list).
Sourcepub fn call_ttl_secs(self, secs: u64) -> ResponseCachingMiddleware
pub fn call_ttl_secs(self, secs: u64) -> ResponseCachingMiddleware
Sets the TTL for call/get/read operations.
Sourcepub fn disable_tools_list(self) -> ResponseCachingMiddleware
pub fn disable_tools_list(self) -> ResponseCachingMiddleware
Disables caching for tools/list.
Sourcepub fn disable_resources_list(self) -> ResponseCachingMiddleware
pub fn disable_resources_list(self) -> ResponseCachingMiddleware
Disables caching for resources/list.
Sourcepub fn disable_prompts_list(self) -> ResponseCachingMiddleware
pub fn disable_prompts_list(self) -> ResponseCachingMiddleware
Disables caching for prompts/list.
Sourcepub fn disable_tools_call(self) -> ResponseCachingMiddleware
pub fn disable_tools_call(self) -> ResponseCachingMiddleware
Disables caching for tools/call.
Sourcepub fn disable_resources_read(self) -> ResponseCachingMiddleware
pub fn disable_resources_read(self) -> ResponseCachingMiddleware
Disables caching for resources/read.
Sourcepub fn disable_prompts_get(self) -> ResponseCachingMiddleware
pub fn disable_prompts_get(self) -> ResponseCachingMiddleware
Disables caching for prompts/get.
Sourcepub fn include_tools(self, tools: Vec<String>) -> ResponseCachingMiddleware
pub fn include_tools(self, tools: Vec<String>) -> ResponseCachingMiddleware
Sets the list of tools to include in caching (empty = all).
Sourcepub fn exclude_tools(self, tools: Vec<String>) -> ResponseCachingMiddleware
pub fn exclude_tools(self, tools: Vec<String>) -> ResponseCachingMiddleware
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.