Registry / database / recacheman-redis

recacheman-redis

JSON →
library4.2.0jsnpmunverified

Redis standalone caching library for Node.js and cache engine for cacheman. Version 4.2.0 uses redis library 5.x. Supports Redis connection via URI, options object, or client instance. TTL support. Callback-based API. Ships TypeScript definitions. A maintained fork of cacheman-redis.

npm install recacheman-redis
INSTALL
IMPORT
SIG · RECACHEMAN-REDIS
R
recacheman-redis
databasejavascriptv4.2.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.

CachemanRedis
✓ var CachemanRedis = require('recacheman-redis');
✗ import CachemanRedis from 'recacheman-redis';
Package uses CommonJS; no default ES module export. Use require().
CachemanRedis
✓ import CachemanRedis = require('recacheman-redis');
✗ import { CachemanRedis } from 'recacheman-redis';
TypeScript: use import = require() due to CJS nature. Destructuring import fails.
CachemanRedis
✓ const cache = new CachemanRedis(options);
✗ new CachemanRedis().set(...)
Constructor can take options object, string URL, or client instance. Instantiate first.

Connects to Redis, sets a key, retrieves it, and deletes it using callbacks.

var CachemanRedis = require('recacheman-redis'); var cache = new CachemanRedis({ host: process.env.REDIS_HOST ?? 'localhost', port: parseInt(process.env.REDIS_PORT ?? '6379') }); cache.set('my key', { foo: 'bar' }, function (err) { if (err) throw err; cache.get('my key', function (err, value) { if (err) throw err; console.log(value); // -> { foo: 'bar' } cache.del('my key', function (err) { if (err) throw err; console.log('value deleted'); }); }); });
Debug
Known issues
gotchaConstructor expects different argument shapes; passing options as first arg works, but passing a single string as URL also works. Passing a Redis client object works if it has a 'client' property or directly as the first arg.
fix
Use consistent pattern: new CachemanRedis(options) or new CachemanRedis('redis://...') or new CachemanRedis(client).
affects: >=2.0.0
deprecatedCallback-based API. No promise support built in; must promisify manually.
fix
Use util.promisify or wrap in Promises: const { promisify } = require('util'); const getAsync = promisify(cache.get).bind(cache);
affects: >=2.0.0
gotchaIf using redis 5.x, host and port are not standard options in the underlying redis client; this library maps them but be aware of potential issues with other options.
fix
Prefer URL string or socket options (socket.host, socket.port) instead of host/port.
affects: >=4.0.0
breakingVersion 4.x dropped Node 14 and 16; requires Node 20 or 22.
fix
Upgrade Node.js to version 20 or higher.
affects: >=4.0.0
Errors
Common errors & fixes
TypeError: CachemanRedis is not a constructor
Using ES module import syntax (import) with a CommonJS package.
fix
Use require: var CachemanRedis = require('recacheman-redis');
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server not running or incorrect connection parameters.
fix
Ensure Redis is started. Pass correct host/port or URL.
ERR wrong number of arguments for 'set' command
Passing TTL as separate argument but missing callback, or mixing order.
fix
Use correct signature: cache.set(key, value, [ttl], fn). Ensure last argument is function.
TypeError: cache.get is not a function
Instantiating CachemanRedis incorrectly, e.g., without 'new' or misassigned variable.
fix
Use 'new CachemanRedis()' and assign to a variable.
Upgrade
Version history
4.2.0latest on npm
Audit
Dependencies
redisrequiredThe underlying Redis driver; version 5.x for recacheman-redis 4.x.
Agent activity
9 hits · last 30 days
node
8
Resources
recacheman-redis — npm install recacheman-redis · libregistry