UNPKG

accounts

Version:

Tempo Accounts SDK

22 lines 871 B
import type * as Kv from '../Kv.js'; /** * Reads `key` from a two-tier cache (in-memory L1, `kv`-backed L2). If absent * or expired in both tiers, calls `fn`, stores the result with a * `Date.now() + ttl * 1000` expiry in both tiers, and returns it. Defaults * to caching forever (no expiry). Kv read/write failures are swallowed so * cache misses never break the caller. * * Concurrent calls for the same key share a single `fn()` invocation. */ export declare function cached<value>(kv: Kv.Kv, key: string, fn: () => Promise<value>, options?: cached.Options): Promise<value>; export declare namespace cached { /** Options for `cached()`. */ type Options = { /** * Cache TTL in seconds. Pass `Infinity` to cache forever. * @default Infinity */ ttl?: number | undefined; }; } //# sourceMappingURL=kv.d.ts.map