{"id":46724,"library":"undici-cache-redis","title":"undici-cache-redis","description":"A Redis-backed cache store for undici's cache interceptor, enabling HTTP response caching with Redis. Version 1.0.1 provides features like cache invalidation by tags, client-side caching (tracking cache), and support for managed Redis environments. Built on iovalkey for optimal Redis/Valkey connectivity. It integrates seamlessly with undici's interceptor pipeline and offers a separate RedisCacheManager for advanced cache monitoring and management. Compared to alternatives, it focuses on high performance and flexibility, making it suitable for production Node.js applications that require distributed caching.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/platformatic/undici-cache-redis","tags":["javascript","undici","cache","redis","typescript"],"install":[{"cmd":"npm install undici-cache-redis","lang":"bash","label":"npm"},{"cmd":"yarn add undici-cache-redis","lang":"bash","label":"yarn"},{"cmd":"pnpm add undici-cache-redis","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; named import required.","wrong":"const RedisCacheStore = require('undici-cache-redis').RedisCacheStore","symbol":"RedisCacheStore","correct":"import { RedisCacheStore } from 'undici-cache-redis'"},{"note":"Named export, not default.","wrong":"import RedisCacheManager from 'undici-cache-redis'","symbol":"RedisCacheManager","correct":"import { RedisCacheManager } from 'undici-cache-redis'"},{"note":"Must destructure; no default export.","wrong":"const RedisCacheStore = require('undici-cache-redis')","symbol":"RedisCacheStore (with require)","correct":"const { RedisCacheStore } = require('undici-cache-redis')"}],"quickstart":{"code":"import { Agent, interceptors } from 'undici'\nimport { RedisCacheStore } from 'undici-cache-redis'\n\nconst store = new RedisCacheStore({\n  clientOpts: {\n    host: process.env.REDIS_HOST ?? 'localhost',\n    port: parseInt(process.env.REDIS_PORT ?? '6379'),\n    keyPrefix: 'my-app:cache:'\n  }\n})\n\nconst agent = new Agent()\n  .compose(interceptors.cache({ store }))\n\nconst response = await agent.request({\n  origin: 'https://api.example.com',\n  method: 'GET',\n  path: '/users/123'\n})\n\nconsole.log(await response.body.text())","lang":"typescript","description":"Creates a Redis cache store and composes it with undici's cache interceptor to cache HTTP GET requests."},"warnings":[{"fix":"Upgrade Node.js to 18 or 20.","message":"Version 1.0.0 requires Node.js >= 18 or 20 due to undici dependencies.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure the server includes a header (e.g., 'Cache-Tags') and set 'cacheTagsHeader' to that header name.","message":"The 'cacheTagsHeader' option must match the header sent by the upstream server; otherwise, tag-based invalidation won't work.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use a Redis URL with 'rediss://' or configure TLS options.","message":"Using 'clientOpts' without TLS for production Redis is not recommended; use TLS URLs or set tls: true.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"If providing a pre-configured client, set keyPrefix on that client instead.","message":"The 'keyPrefix' option is passed to iovalkey's createClient; it may be ignored if the client is already created externally.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.0.1':23 'advanc':64 'altern':71 'applic':85 'back':8 'built':43 'cach':3,9,14,19,27,34,36,65,89,92 'client':32 'client-sid':31 'compar':69 'connect':49 'distribut':88 'enabl':16 'environ':42 'featur':25 'flexibl':78 'focus':73 'high':75 'http':17 'integr':51 'interceptor':15,56 'invalid':28 'iovalkey':45 'javascript':90 'like':26 'make':79 'manag':40,68 'monitor':66 'node.js':84 'offer':59 'optim':47 'perform':76 'pipelin':57 'product':83 'provid':24 'redi':4,7,21,41,93 'redis-back':6 'redis/valkey':48 'rediscachemanag':62 'requir':87 'respons':18 'seamless':52 'separ':61 'side':33 'store':10 'suitabl':81 'support':38 'tag':30 'track':35 'typescript':94 'undici':2,12,54,91 'undici-cache-redi':1 'version':22","created_at":"2026-06-07T13:01:19.872767+00:00","updated_at":"2026-06-07T13:01:19.872767+00:00","problems":[{"fix":"npm install undici-cache-redis && ensure using ESM import syntax.","cause":"Package not installed or import path is incorrect.","error":"ERR_MODULE_NOT_FOUND: Cannot find package 'undici-cache-redis'"},{"fix":"Ensure you have instantiated RedisCacheStore from 'undici-cache-redis'.","cause":"Calling deleteTags on a store instance that does not have the method (likely using a different store type).","error":"TypeError: store.deleteTags is not a function"},{"fix":"Start a Redis server or set REDIS_HOST/REDIS_PORT environment variables to point to a running instance.","cause":"Redis server is not running on localhost:6379.","error":"Error: connect ECONNREFUSED 127.0.0.1:6379"}],"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/platformatic/undici-cache-redis#readme","github":"https://github.com/platformatic/undici-cache-redis","docs":null,"changelog":null,"pypi":null,"npm":"undici-cache-redis","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"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}}