Number of live (non-expired) entries currently in the cache.
Generate a deterministic cache key from analysis inputs.
Documents being analysed
Focus topic, or null
Number of analysis iterations
Target language
Cache key string
Retrieve a cached analysis result if it exists and has not expired.
Cache key from generateKey()
Cached result, or undefined if absent / expired
Store an analysis result in the cache.
Cache key from generateKey()
Analysis result to cache
Time-to-live in milliseconds (default: 30 min)
Remove all expired entries from the cache.
Called opportunistically from set() to prevent memory growth in
long-lived processes. Also enforces a maximum cache size.
Remove all entries from the cache.
Cache for AI analysis results.
Thread-safety note: Node.js is single-threaded; concurrent async access is fine without additional locking.