Registry / database / redis-cache-manager

redis-cache-manager

JSON →
library1.0.93jsnpmunverified

A caching library for Node.js that uses Redis with built-in pub/sub support. Version 1.0.93 provides a simple API for caching objects and arrays as JSON strings or Redis hashes, with automatic key scoping via namespace. It supports basic CRUD operations like set, get, setAll, getAll, getByIds, and hash-based operations (hmSetAll, hmSetOne, hmGetAll). Every set operation can optionally subscribe listeners to receive updates. The library wraps ioredis internally and offers TypeScript typings. Compared to other Redis cache managers, its key differentiators are the integrated pub/sub for real-time updates and the ability to cache complex data structures with automatic serialization. Release cadence appears irregular with few recent updates.

npm install redis-cache-manager
INSTALL
IMPORT
SIG · REDIS-CACHE-MANAGE
R
redis-cache-manager
databasejavascriptv1.0.93
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.

RedisCacheManager
✓ import { RedisCacheManager } from 'redis-cache-manager'
✗ const RedisCacheManager = require('redis-cache-manager')
ESM default export not available; named export only.
RedisCacheManager
✓ const { RedisCacheManager } = require('redis-cache-manager')
✗ const RedisCacheManager = require('redis-cache-manager').default
CJS users must destructure the named export, not access .default.
types
✓ import type { Config } from 'redis-cache-manager'
TypeScript types are exported for the constructor config object.

Demonstrates initialization, setting/getting simple keys, and using setAll/getAll with a unique ID callback.

import { RedisCacheManager } from 'redis-cache-manager'; const rcm = new RedisCacheManager({ namespace: 'my-app', host: process.env.REDIS_HOST ?? 'localhost', port: parseInt(process.env.REDIS_PORT ?? '6379'), }); // Set a simple key await rcm.set('user:123', { name: 'Alice', email: 'alice@example.com' }); // Get the key const user = await rcm.get('user:123'); console.log(user); // { name: 'Alice', email: 'alice@example.com' } // Set multiple items with callback for ID const items = [{ id: 1, value: 'a' }, { id: 2, value: 'b' }]; await rcm.setAll('my-list', items, (item) => item.id); // Get all items const allItems = await rcm.getAll('my-list'); console.log(allItems); // [{ id: 1, value: 'a' }, { id: 2, value: 'b' }]
Debug
Known issues
gotchaAll values are stored as JSON strings via JSON.stringify/JSON.parse. Functions, undefined, and circular references may fail.
fix
Ensure cached values are JSON-serializable. Use a custom serialization method if needed.
affects: >=1.0.0
gotchaset() and get() do not handle expiration/TTL by default. Keys persist indefinitely unless manually deleted.
fix
Manually call Redis EXPIRE after setting or use a wrapper.
affects: >=1.0.0
deprecatedConstructor expects ioredis config object but does not accept a pre-configured client. You must provide host, port, etc.
fix
Pass full ioredis options to constructor.
affects: >=1.0.0
breakingAll methods return promises; forgeting to await may cause unexpected behavior.
fix
Always await calls to set, get, setAll, etc.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: rcm.set is not a function
Forgetting to import RedisCacheManager correctly (default vs named import).
fix
Use import { RedisCacheManager } from 'redis-cache-manager' or const { RedisCacheManager } = require('redis-cache-manager').
Error: namespace is required
Constructor called without namespace property.
fix
Pass { namespace: 'your-namespace' } to RedisCacheManager constructor.
Error: listen is not a function
Attempting to use pub/sub listener incorrectly; listener is optional second callback in set() method.
fix
Pass listener as third argument: rcm.set('key', value, callback).
Upgrade
Version history
1.0.93latest on npm
Audit
Dependencies
ioredisrequiredRedis client dependency required for all operations.
Agent activity
25 hits · last 30 days
node
22
Resources
redis-cache-manager — npm install redis-cache-manager · libregistry