Caching
Prism provides two caching layers:PrismCache for general-purpose key-value caching, and PrismResponseCacheMiddleware for automatic HTTP response caching with ETag and Cache-Control support.
PrismCache
An actor-based LRU cache with time-to-live eviction:Basic Cache Usage
Cache Operations
Cache API
LRU Eviction
When the cache exceedsmaxEntries, the least recently used entries are evicted first. Accessing an entry via get promotes it to most-recently-used.
LRU Behavior
Response Cache Middleware
Automatically cache HTTP responses with proper ETag and Cache-Control headers:Enable Response Caching
How It Works
- Cache MISS — request passes through, response is cached and returned with
X-Cache: MISS,ETag, andCache-Controlheaders - Cache HIT — cached response returned immediately with
X-Cache: HIT - Conditional request — if client sends
If-None-Matchmatching the ETag, returns304 Not Modified(no body)
Cache Headers
Custom Cache Predicate
By default, only GET requests are cached. Customize this:Custom Predicate
Practical Example: Expensive Query Cache
Cache Database Results