A lightweight zero-dependency async cache library for Node.js and browser (current version 2.0.0). It caches async data sources (Promise-returning functions) with configurable TTL, prevents duplicate concurrent requests for the same key (deduplication), and supports forced refresh and per-key clearing. Released in 2016 and still maintained with a small API surface. Compared to alternatives like lru-cache or node-cache, async-cacher focuses solely on async cache coordination with built-in deduplication.
npm install async-cacherNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: instantiate Cache, cache an async data source per key with optional TTL, force refresh, and clear a specific key.
Use import { Cache } from 'async-cacher' or dynamic import().Replace cache(options) with new Cache() and cache.get(options).
Handle errors in dataSource or wrap in try-catch around cache.get.
Use a Redis-backed cache for persistent/distributed caching.
Consider migrating to active alternatives like lru-cache or cache-manager-memory-store.
Use import { Cache } from 'async-cacher' instead of import Cache from 'async-cacher'.Switch to ESM import or use dynamic import: const { Cache } = await import('async-cacher');Upgrade to v2 and use new Cache() then cache.get({...}).No dependency data recorded yet.