| 139 | /** Public cache. Counters are emitted on every get/put for hit-rate observability. */ |
| 140 | export const cache: PromptCache = { |
| 141 | async get(key: string): Promise<CacheEntry | null> { |
| 142 | const e = await __backend.get(key); |
| 143 | counter(e ? "cognition.cache_hit" : "cognition.cache_miss"); |
| 144 | return e; |
| 145 | }, |
| 146 | async put(key, prompt_name, model_id, value, ttl_ms, usage): Promise<void> { |
| 147 | await __backend.put(key, prompt_name, model_id, value, ttl_ms, usage); |
| 148 | counter("cognition.cache_put", { prompt: prompt_name }); |