cajache is a minimalistic in-memory caching library for JavaScript/TypeScript (v2.0.2, released 2023). It provides a simple API to cache any asynchronous function result, with optional TTL support and configurable expiration check intervals. Unlike larger caching libraries like node-cache or lru-cache, cajache has zero dependencies and is very lightweight (~1KB minzipped). Its key differentiator is the `.use()` method that automatically handles cache miss/miss logic, reducing boilerplate. The library supports persistent (no TTL) and time-based caching, multiple instances, and path-based caching for nested results. It ships TypeScript definitions.
npm install cajacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of cajache: permanent caching, TTL caching, and creating a new instance.
Wrap any pre-existing promise in an arrow function: `() => myPromise`.
Set `checkInterval` in constructor options to a smaller value if more immediate cleanup is needed.
Ensure the path only references simple object keys without dots or special characters.
Use `const cajache = require('cajache')` for CommonJS, or `import cajache from 'cajache'` for ESM.Ensure the second argument is a function: `() => yourCode`.
No dependency data recorded yet.