A Redis caching middleware for tRPC (v0.4.0) that provides type-safe caching for tRPC procedures with support for standard Redis and Upstash Redis. Released with no fixed cadence, this library offers both global and user-specific caching strategies, custom TTL, built-in logging, and cache invalidation. Differentiators include tight integration with tRPC v11, TypeScript-first design, and minimal configuration overhead compared to generic Redis caching solutions.
npm install trpc-redis-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a cache middleware with a 60-second TTL, apply it to a tRPC query, and invalidate the cache for a specific procedure and user.
Ensure your project uses tRPC v11.7.1 or later.
Set environment variables or pass options explicitly: createCacheMiddleware({ useUpstash: true, url: '...', token: '...' })Always pass identical options to createCacheMiddleware and invalidateCache.
Remove 'debug' option from configuration; use console.log or a logging library instead.
Run 'npm install trpc-redis-cache' and ensure package.json includes it.
Use 'import { createCacheMiddleware } from 'trpc-redis-cache'' and ensure package.json has 'type': 'module'.Switch to ESM syntax: 'import { createCacheMiddleware } from 'trpc-redis-cache''. If you need CJS, use dynamic import().