{"id":45161,"library":"ioredis-cache","title":"ioredis-cache","description":"A promise-based caching library built on top of ioredis for Node.js applications. Version 2.0.3 wraps ioredis to provide a compact, memory-efficient caching interface using Redis hashes. Supports standard cache, hash cache, batch operations, TTL expiration, pattern-based deletion, and atomic acquire operations. Ships TypeScript types. Release cadence is low; maintainer activity has been minimal since late 2023. Differentiators: promise-based API, hash map storage for memory efficiency, and built-in `manyCache` to batch uncached keys.","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/eluneevermore/ioredis-cache","tags":["javascript","redis","cache","ioredis","store","typescript"],"install":[{"cmd":"npm install ioredis-cache","lang":"bash","label":"npm"},{"cmd":"yarn add ioredis-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add ioredis-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Redis client functionality","package":"ioredis","optional":false}],"imports":[{"note":"Default import is CommonJS compatible; TypeScript also allows `import Cache from 'ioredis-cache'`.","wrong":"const Cache = require('ioredis-cache')","symbol":"default","correct":"import Cache from 'ioredis-cache'"},{"note":"Type only export; use type import for TypeScript.","wrong":"import { CacheOptions } from 'ioredis-cache' (if not using type import)","symbol":"CacheOptions","correct":"import type { CacheOptions } from 'ioredis-cache'"},{"note":"Type only export.","wrong":"import { Parser } from 'ioredis-cache' (not a runtime export)","symbol":"Parser","correct":"import type { Parser } from 'ioredis-cache'"}],"quickstart":{"code":"import Redis from 'ioredis';\nimport Cache from 'ioredis-cache';\n\nconst redis = new Redis();\nconst cache = new Cache(redis);\n\nasync function main() {\n  const value = await cache.cache('myKey', async () => {\n    const result = await fetch('https://api.example.com/data');\n    return result.json();\n  }, 3600);\n  \n  console.log(value);\n  const cached = await cache.getCache('myKey');\n  console.log(cached);\n  await cache.deleteCache('myKey');\n  redis.quit();\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Demonstrates basic cache, retrieving, and deleting a cached value with TTL, using TypeScript."},"warnings":[{"fix":"Always pass a configured ioredis instance or an object with `redis` property set to an ioredis instance.","message":"Constructor argument expects an ioredis instance or CacheOptions object, not a plain Redis options object.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Create an ioredis instance first: `new Redis('redis://...')` then pass to constructor.","message":"In version 2.0.0, the constructor no longer accepts just a Redis URL string; it must be an ioredis instance or CacheOptions.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use ES module import syntax: `import Cache from 'ioredis-cache'`.","message":"Using `require('ioredis-cache')` with CommonJS is deprecated in favor of ES modules.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure the callback returns a non-undefined value if caching is desired.","message":"Calling `cache#cache` with a callback that returns `undefined` will not store the result.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Specify TTL as number of seconds (e.g., 3600 for one hour).","message":"The `ttl` parameter is in seconds, not milliseconds.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Directly call `redis.quit()` on the ioredis instance you created.","message":"Using `cache.redis.quit()` to disconnect is a workaround, not a documented API.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.0.3':19 '2023':65 'acquir':49 'activ':59 'api':70 'applic':17 'atom':48 'base':7,45,69 'batch':39,83 'built':10,79 'built-in':78 'cach':3,8,29,36,38,88 'cadenc':55 'compact':25 'delet':46 'differenti':66 'effici':28,76 'expir':42 'hash':33,37,71 'interfac':30 'ioredi':2,14,21,89 'ioredis-cach':1 'javascript':86 'key':85 'late':64 'librari':9 'low':57 'maintain':58 'manycach':81 'map':72 'memori':27,75 'memory-effici':26 'minim':62 'node.js':16 'oper':40,50 'pattern':44 'pattern-bas':43 'promis':6,68 'promise-bas':5,67 'provid':23 'redi':32,87 'releas':54 'ship':51 'sinc':63 'standard':35 'storag':73 'store':90 'support':34 'top':12 'ttl':41 'type':53 'typescript':52,91 'uncach':84 'use':31 'version':18 'wrap':20","created_at":"2026-06-07T12:53:39.970641+00:00","updated_at":"2026-06-07T12:53:39.970641+00:00","problems":[{"fix":"Use `new Cache(redis)` instead of `Cache(redis)`.","cause":"Trying to call `Cache(...)` without the `new` keyword.","error":"TypeError: Class constructor Cache cannot be invoked without 'new'"},{"fix":"Start Redis server or provide correct connection options to ioredis.","cause":"No Redis server running at the default host/port.","error":"Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED"},{"fix":"Import ioredis: `import Redis from 'ioredis'` or `const Redis = require('ioredis')`.","cause":"Using `new Redis()` without importing ioredis correctly.","error":"TypeError: Redis is not a constructor"}],"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/eluneevermore/ioredis-cache#readme","github":"https://github.com/eluneevermore/ioredis-cache","docs":null,"changelog":null,"pypi":null,"npm":"ioredis-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["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}}