Registry / database / cacheman

cacheman

JSON →
library2.2.1jsnpmunverified

A small and efficient cache provider for Node.js that supports in-memory, file, Redis, and MongoDB engines. Version 2.2.1 allows flexible configuration with TTL, custom delimiters, and Promise support. It provides a simple unified API (set, get, del, clear) with both callback and Promise interfaces. Unlike single-engine caches, cacheman lets you switch engines without changing application code, making it ideal for development vs production environments.

npm install cacheman
INSTALL
IMPORT
SIG · CACHEMAN
C
cacheman
databasejavascriptv2.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Cacheman
✓ import Cacheman from 'cacheman'
✗ const Cacheman = require('cacheman')
ESM only since v2.0.0
Cacheman constructor
✓ const cache = new Cacheman();
✗ const cache = Cacheman();
Must use new keyword
Cacheman with options
✓ const cache = new Cacheman('myapp', { ttl: 300, engine: 'redis' });
✗ const cache = new Cacheman({ engine: 'redis' });
When passing engine options as second arg, first arg must be the name

Creates a cache instance with a 60-second TTL, stores and retrieves a user object, then deletes and clears.

import Cacheman from 'cacheman'; const cache = new Cacheman('myapp', { ttl: 60 }); await cache.set('user', { name: 'Alice' }); const user = await cache.get('user'); console.log(user); // { name: 'Alice' } await cache.del('user'); await cache.clear(); console.log('done');
Debug
Known issues
deprecatedCallback API is deprecated in favor of Promises
fix
Use async/await or .then() instead of callbacks
affects: >=2.0.0
gotchaEngine must be installed separately; no runtime dependency
fix
Install engine package (e.g., npm install cacheman-redis) and pass name as string
affects: >=2.0.0
gotchaTLL value accepts human-readable strings (e.g., '1m') but only if you install the 'ms' package
fix
Import 'ms' or use numeric seconds directly
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'cacheman-redis'
Redis engine not installed
fix
Run: npm install cacheman-redis
TypeError: Cacheman is not a constructor
Using import incorrectly or missing new keyword
fix
Use: const cache = new Cacheman();
TypeError: cache.set(...).then is not a function
Using Promises without Promise library or mixing callbacks into promise chain
fix
Ensure global Promise is available or use callbacks
Upgrade
Version history
2.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
cacheman — npm install cacheman · libregistry