Skip to main content

Module cache

Module cache 

Source
Expand description

Redis-backed exact-match response cache.

The cache key is a SHA-256 hash of the canonical JSON serialization of the ChatRequest. Because the request struct derives [Serialize], the hash is deterministic for identical requests regardless of field insertion order (serde always serialises struct fields in declaration order).

Cache entries expire after DEFAULT_TTL_SECS seconds; callers can override this via ExactMatchCache::with_ttl.

The cache gracefully degrades: if Redis is unavailable all get/set calls return None/Ok(()) without surfacing errors to the caller.

Structs§

ExactMatchCache
Exact-match Redis cache for ChatResponse values.

Constants§

DEFAULT_TTL_SECS
Default TTL for cached responses (5 minutes).