NestJS is a progressive Node.js framework for building efficient, scalable server-side applications. It is built with TypeScript and combines elements of OOP (Object-Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming). It uses Express or Fastify under the hood.

Redis integration in NestJS

NestJS offers two distinct Redis integration paths:

  1. Microservices transport: Via @nestjs/microservices, using Transport.REDIS with the Redis Transporter for pub/sub messaging between services.
  2. Caching: Via @nestjs/common’s CacheModule and CacheInterceptor, which provide a store-agnostic caching layer. The cache-manager-redis-store adapter connects this layer to Redis.

A third, manual approach uses ioredis directly in custom providers, without relying on NestJS abstractions.

Key imports

  • @nestjs/microservicesTransport, ClientProxy, MessagePattern, EventPattern, RedisContext
  • @nestjs/commonCacheModule, CacheInterceptor, CacheKey, CacheTTL, CACHE_MANAGER