{"id":46082,"library":"redis-cache-manager","title":"Redis Cache Manager","description":"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.","status":"active","version":"1.0.93","language":"javascript","source_language":"en","source_url":"https://github.com/NitayRabi/redis-cache-manager","tags":["javascript","redis","cache","pub","sub","typescript"],"install":[{"cmd":"npm install redis-cache-manager","lang":"bash","label":"npm"},{"cmd":"yarn add redis-cache-manager","lang":"bash","label":"yarn"},{"cmd":"pnpm add redis-cache-manager","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Redis client dependency required for all operations.","package":"ioredis","optional":false}],"imports":[{"note":"ESM default export not available; named export only.","wrong":"const RedisCacheManager = require('redis-cache-manager')","symbol":"RedisCacheManager","correct":"import { RedisCacheManager } from 'redis-cache-manager'"},{"note":"CJS users must destructure the named export, not access .default.","wrong":"const RedisCacheManager = require('redis-cache-manager').default","symbol":"RedisCacheManager","correct":"const { RedisCacheManager } = require('redis-cache-manager')"},{"note":"TypeScript types are exported for the constructor config object.","wrong":"","symbol":"types","correct":"import type { Config } from 'redis-cache-manager'"}],"quickstart":{"code":"import { RedisCacheManager } from 'redis-cache-manager';\n\nconst rcm = new RedisCacheManager({\n  namespace: 'my-app',\n  host: process.env.REDIS_HOST ?? 'localhost',\n  port: parseInt(process.env.REDIS_PORT ?? '6379'),\n});\n\n// Set a simple key\nawait rcm.set('user:123', { name: 'Alice', email: 'alice@example.com' });\n\n// Get the key\nconst user = await rcm.get('user:123');\nconsole.log(user); // { name: 'Alice', email: 'alice@example.com' }\n\n// Set multiple items with callback for ID\nconst items = [{ id: 1, value: 'a' }, { id: 2, value: 'b' }];\nawait rcm.setAll('my-list', items, (item) => item.id);\n\n// Get all items\nconst allItems = await rcm.getAll('my-list');\nconsole.log(allItems); // [{ id: 1, value: 'a' }, { id: 2, value: 'b' }]","lang":"typescript","description":"Demonstrates initialization, setting/getting simple keys, and using setAll/getAll with a unique ID callback."},"warnings":[{"fix":"Ensure cached values are JSON-serializable. Use a custom serialization method if needed.","message":"All values are stored as JSON strings via JSON.stringify/JSON.parse. Functions, undefined, and circular references may fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Manually call Redis EXPIRE after setting or use a wrapper.","message":"set() and get() do not handle expiration/TTL by default. Keys persist indefinitely unless manually deleted.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pass full ioredis options to constructor.","message":"Constructor expects ioredis config object but does not accept a pre-configured client. You must provide host, port, etc.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Always await calls to set, get, setAll, etc.","message":"All methods return promises; forgeting to await may cause unexpected behavior.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.93':19 'abil':99 'api':23 'appear':110 'array':28 'automat':36,106 'base':55 'basic':43 'built':14 'built-in':13 'cach':2,5,25,83,101,118 'cadenc':109 'compar':79 'complex':102 'crud':44 'data':103 'differenti':87 'everi':60 'get':48 'getal':50 'getbyid':51 'hash':34,54 'hash-bas':53 'hmgetal':59 'hmsetal':57 'hmseton':58 'integr':90 'intern':74 'ioredi':73 'irregular':111 'javascript':116 'json':30 'key':37,86 'librari':6,71 'like':46 'listen':66 'manag':3,84 'namespac':40 'node.js':8 'object':26 'offer':76 'oper':45,56,62 'option':64 'provid':20 'pub':119 'pub/sub':16,91 'real':94 'real-tim':93 'receiv':68 'recent':114 'redi':1,11,33,82,117 'releas':108 'scope':38 'serial':107 'set':47,61 'setal':49 'simpl':22 'string':31 'structur':104 'sub':120 'subscrib':65 'support':17,42 'time':95 'type':78 'typescript':77,121 'updat':69,96,115 'use':10 'version':18 'via':39 'wrap':72","created_at":"2026-06-07T12:58:11.670954+00:00","updated_at":"2026-06-07T12:58:11.670954+00:00","problems":[{"fix":"Use import { RedisCacheManager } from 'redis-cache-manager' or const { RedisCacheManager } = require('redis-cache-manager').","cause":"Forgetting to import RedisCacheManager correctly (default vs named import).","error":"TypeError: rcm.set is not a function"},{"fix":"Pass { namespace: 'your-namespace' } to RedisCacheManager constructor.","cause":"Constructor called without namespace property.","error":"Error: namespace is required"},{"fix":"Pass listener as third argument: rcm.set('key', value, callback).","cause":"Attempting to use pub/sub listener incorrectly; listener is optional second callback in set() method.","error":"Error: listen is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/NitayRabi/redis-cache-manager#readme","github":"https://github.com/NitayRabi/redis-cache-manager","docs":null,"changelog":null,"pypi":null,"npm":"redis-cache-manager","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}