cache<T>(key: string | string[],value: () => T | Promise<T>,options?: { timeout?: number; },): Promise<T>
Fetch and cache expensive computations using Deno KV.
Caches the result of an async function call. If the cached value exists and hasn't expired, returns it immediately. Otherwise, calls the function, caches the result, and returns it.
Use cases:
- Cache expensive API calls
- Store computed results between runs
- Reduce redundant processing
- Implement time-based invalidation
Promise<T>
The cached or computed value.