{"id":45745,"library":"payloadcms-redis-cache","title":"payloadcms-redis-cache","description":"A lightweight Redis caching utility for Payload CMS v3 and Next.js 14+ App Router applications, currently at version 1.0.3. It provides a simple Redis client wrapper, server-only safe, with TypeScript and ESM support. Key differentiators: designed specifically for Payload CMS v3, supports collection caching and cache invalidation hooks, and includes examples for API routes and Next.js client components. The package is actively maintained by a single author and has an MIT license.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","payloadcms","payload","nextjs","redis","cache","typescript"],"install":[{"cmd":"npm install payloadcms-redis-cache","lang":"bash","label":"npm"},{"cmd":"yarn add payloadcms-redis-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add payloadcms-redis-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Redis client used internally","package":"ioredis","optional":false}],"imports":[{"note":"Named export, not default. In ESM, use named import.","wrong":"import redis from 'payloadcms-redis-cache'","symbol":"redis","correct":"import { redis } from 'payloadcms-redis-cache'"},{"note":"This symbol is not documented yet but may be added in future. For v1.0.3, only redis is exported.","wrong":"const PayloadCache = require('payloadcms-redis-cache').PayloadCache","symbol":"PayloadCache","correct":"import { PayloadCache } from 'payloadcms-redis-cache'"},{"note":"The exported object is named 'redis'. There is no 'redisClient'. Use the correct name.","wrong":"import { redisClient } from 'payloadcms-redis-cache'","symbol":"redisClient","correct":"import { redis } from 'payloadcms-redis-cache'"}],"quickstart":{"code":"import { redis } from 'payloadcms-redis-cache'\n\nasync function example() {\n  await redis.set('hello', 'world', { EX: 60 })\n  const value = await redis.get('hello')\n  console.log(value) // 'world'\n}","lang":"typescript","description":"Demonstrates basic Redis set and get operations using the exported redis client. Shows TTL option."},"warnings":[{"fix":"Run 'npm install ioredis' if missing.","message":"The redis instance is a thin wrapper around ioredis. Ensure ioredis is installed as a peer dependency or included automatically.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Only use in server components, API routes, or server actions.","message":"Do not import or use redis inside Next.js client components or browser code. It will throw errors at runtime because ioredis uses Node.js APIs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pin version to avoid breaking changes: 'payloadcms-redis-cache': '1.0.3'","message":"The package is in early development (v1.0.3); API may change. No deprecations yet.","severity":"deprecated","affected_versions":"1.0.3"},{"fix":"Set .env or process.env values before calling redis methods.","message":"Ensure REDIS_HOST, REDIS_PORT, and REDIS_PASSWORD environment variables are set. Missing variables cause silent connection failures.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.3':23 '14':16 'activ':68 'api':59 'app':17 'applic':19 'author':73 'cach':4,8,50,52,84 'client':29,63 'cms':12,46 'collect':49 'compon':64 'current':20 'design':42 'differenti':41 'esm':38 'exampl':57 'hook':54 'includ':56 'invalid':53 'javascript':79 'key':40 'licens':78 'lightweight':6 'maintain':69 'mit':77 'next.js':15,62 'nextj':82 'packag':66 'payload':11,45,81 'payloadcm':2,80 'payloadcms-redis-cach':1 'provid':25 'redi':3,7,28,83 'rout':60 'router':18 'safe':34 'server':32 'server-on':31 'simpl':27 'singl':72 'specif':43 'support':39,48 'typescript':36,85 'util':9 'v3':13,47 'version':22 'wrapper':30","created_at":"2026-06-07T12:56:31.004261+00:00","updated_at":"2026-06-07T12:56:31.004261+00:00","problems":[{"fix":"Start Redis server (e.g., 'brew services start redis' on Mac). Verify REDIS_HOST and REDIS_PORT.","cause":"Redis server not running or environment variables misconfigured.","error":"Redis connection error: connect ECONNREFUSED 127.0.0.1:6379"},{"fix":"Use 'import { redis } from 'payloadcms-redis-cache' instead of 'import redis from ...'","cause":"Importing incorrectly (default import instead of named).","error":"UnhandledPromiseRejectionWarning: TypeError: redis.set is not a function"},{"fix":"Move redis usage to server-only code: API routes, server components, or server actions.","cause":"Using ioredis (Node.js) in browser environment.","error":"ReferenceError: window is not defined"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"payloadcms-redis-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops"],"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}}