Registry / database / cacheman-redis

cacheman-redis

JSON →
library2.1.0jsnpmunverified

Redis standalone caching library for Node.js and cache engine for cacheman. Current stable version is 2.1.0. Provides a simple API for caching with Redis, supporting TTL, connection strings, and client reuse. Designed to work with the cacheman ecosystem but can be used standalone. Uses the `redis` package v2.x as a peer dependency. Release cadence is low; the package is in maintenance mode with infrequent updates.

npm install cacheman-redis
INSTALL
IMPORT
SIG · CACHEMAN-REDIS
C
cacheman-redis
databasejavascriptv2.1.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
const CachemanRedis = require('cacheman-redis');
import CachemanRedis from 'cacheman-redis';
Package provides CommonJS modules only; ES imports are not supported.
CachemanRedis with options
const cache = new CachemanRedis({ port: 6379, host: '127.0.0.1', password: 'pw', database: 0 });
const cache = new CachemanRedis({ url: 'redis://...' });
Use connection string directly as first argument instead of url property.
CachemanRedis with existing client
const client = require('redis').createClient(); const cache = new CachemanRedis(client);
const cache = new CachemanRedis({ client: client });
Passing an existing client instance directly works too; both patterns are supported.

Demonstrates basic CRUD operations: set, get, and delete a cache entry with TTL.

const CachemanRedis = require('cacheman-redis'); const cache = new CachemanRedis(); cache.set('mykey', { foo: 'bar' }, 60, (err) => { if (err) throw err; cache.get('mykey', (err, value) => { if (err) throw err; console.log(value); // { foo: 'bar' } cache.del('mykey', (err) => { if (err) throw err; console.log('deleted'); }); }); });
Debug
Known issues
gotchaTTL is in seconds, not milliseconds.
fix
Ensure TTL values are seconds; multiply by 1000 if converting from milliseconds.
affects: >=1.0.0
gotchaThe package uses the 'redis' v2.x peer dependency which may conflict with newer 'redis' v4+.
fix
Install 'redis@2' as a dependency, or use a compatibility layer.
affects: >=2.0.0
gotchaError handling: callbacks must have error as first argument; missing error check can cause crashes.
fix
Always check `err` in callbacks before using the result.
affects: >=1.0.0
gotchaThe package is not actively maintained; issues and PRs may not be addressed.
fix
Consider alternative caching libraries like 'cache-manager-redis-store' or 'ioredis'.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server is not running or inaccessible with the provided host and port.
fix
Start Redis server or configure correct host/port in options.
Error: The client is closed
Redis client is closed before performing operations.
fix
Ensure the cache client is created after Redis is connected, or reuse an existing open client.
TypeError: cache.set is not a function
Cache instance not properly initialized due to invalid options.
fix
Check constructor arguments: options object or connection string must be valid.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
redisrequiredPeer dependency; required for Redis client functionality
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
cacheman-redis — npm install cacheman-redis · libregistry