Skip to main content

Module cache

Module cache 

Source
Expand description

Response caching middleware for the proxy.

Caches ReadResource and CallTool responses with per-backend TTL. Cache keys are derived from the request type, name/URI, and arguments.

§Cache Backends

The cache backend is configurable via [cache] in the proxy config:

  • "memory" (default): In-process moka cache. Fast, no external deps.
  • "redis": External Redis cache. Shared across instances. Requires the redis-cache feature flag.
  • "sqlite": Local SQLite cache. Persistent across restarts. Requires the sqlite-cache feature flag.

§Per-Backend Configuration

[[backends]]
name = "slow-api"
transport = "http"
url = "http://localhost:8080"

[backends.cache]
resource_ttl_seconds = 300
tool_ttl_seconds = 60
max_entries = 1000

Structs§

CacheHandle
Shared handle for querying cache stats and clearing caches.
CacheLayer
Tower Layer that produces CacheService instances sharing the same cache state and CacheHandle.
CacheService
Tower service that caches resource reads and tool call results.
CacheStatsSnapshot
Snapshot of cache statistics for a single backend.