A TypeScript promise-based loading cache that prevents thundering herds (cache stampede). Version 0.9.0 is the latest stable release. Ships with TypeScript definitions. Low release cadence. Differentiators: configurable TTL (access- or write-based), separate cache for single values, statistics, explicit set method, and customizable rejection handling with optional retry via ts-retry-promise.
npm install ts-promise-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a PromiseCache with a loader, retrieves a value, and logs cache statistics.
Set ttl and checkInterval when creating cache to avoid unbounded memory growth.
Override onReject to handle retries or provide fallback values.
Ensure loader returns a Promise; for synchronous loads, wrap in Promise.resolve().
Review the GitHub releases for migration notes.
import { PromiseCache } from 'ts-promise-cache'Update to 0.9.0: npm install ts-promise-cache@latest
const cachedFn = singlePromiseCache(loader); const value = await cachedFn();
No dependency data recorded yet.