Registry / storage / recacheman

recacheman

JSON →
library3.0.0jsnpmunverified

Recacheman v3.0.0 is a small, efficient Node.js cache provider forked from cacheman, supporting in-memory, file, Redis, and MongoDB backends. Provides a unified API with TTL support (including ms-format strings), event hooks, and promise/async/await compatibility. Ships TypeScript definitions. Released semver; v3 drops Node 10/12/14/16/18 support, requires Node 20+. Alternatives: node-cache (memory-only), cacheman (original, less maintained).

npm install recacheman
INSTALL
IMPORT
SIG · RECACHEMAN
R
recacheman
storagejavascriptv3.0.0
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 'recacheman'
const Cacheman = require('recacheman')
Package is ESM-only since v3. CommonJS require will throw ERR_REQUIRE_ESM
Cacheman (as constructor)
const cache = new Cacheman()
const cache = Cacheman()
Cacheman must be instantiated with 'new'. Missing new operator will return undefined or throw.
Cacheman with options
import Cacheman from 'recacheman'; const cache = new Cacheman({ engine: 'redis' })
import { Cacheman } from 'recacheman'
Cacheman is a default export. Named import will be undefined.

Shows ESM import, Redis engine instantiation, set/get/delete with promises, and TTL in seconds.

import Cacheman from 'recacheman'; import { createClient } from 'redis'; const cache = new Cacheman('myapp', { engine: 'redis', client: createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' }) }); await cache.set('user:123', { name: 'Alice' }, 60); const user = await cache.get('user:123'); console.log(user); // { name: 'Alice' } await cache.del('user:123');
Debug
Known issues
breakingv3 drops support for Node.js versions <20 (10, 12, 14, 16, 18)
fix
Upgrade Node.js to 20+ or stick with recacheman@2.x
affects: >=3.0.0
breakingv3 is ESM-only – CommonJS require() throws ERR_REQUIRE_ESM
fix
Use import statement or dynamic import() in CommonJS
affects: >=3.0.0
gotchaCacheman constructor must be called with 'new' – missing throws TypeError
fix
Always use 'new Cacheman(...)'
affects: >=2.0.0
deprecatedCallback style is deprecated in v3 – use promises/async-await
fix
Use .then() or async/await instead of callbacks
affects: >=3.0.0
gotchaArray keys are joined with delimiter ':' by default – 'set(['foo','bar'], value)' stores under key 'foo:bar'
fix
Use string keys for exact control, or set delimiter option
affects: >=1.0.0
gotchaTTL in ms format (e.g., '1m') uses the 'ms' library – invalid strings may throw or default to undefined TTL
fix
Pass valid ms strings or numeric seconds
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Class constructor Cacheman cannot be invoked without 'new'
Missing 'new' keyword when creating Cacheman instance
fix
const cache = new Cacheman(...)
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported
Using require() with recacheman v3+ which is ESM-only
fix
Use import Cacheman from 'recacheman' or dynamic import()
TypeError: cache.set(...).then is not a function
Using callback syntax without a callback – returns undefined instead of a promise
fix
Pass a callback or use async/await. Check if promises are enabled via options.Promise
TypeError: Cannot read properties of undefined (reading 'get')
Trying to import Cacheman as named export – it's a default export
fix
import Cacheman from 'recacheman' (not import { Cacheman } from 'recacheman')
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
cacheman-memoryrequiredDefault in-memory engine – always installed
cacheman-fileoptionalOptional file-based engine – only needed if using file store
cacheman-redisoptionalOptional Redis engine – only needed if using Redis store
cacheman-mongooptionalOptional MongoDB engine – only needed if using MongoDB store
Agent activity
24 hits · last 30 days
node
20
Meta
1
Amazon
1
Resources
recacheman — npm install recacheman · libregistry