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:
- Microservices transport: Via
@nestjs/microservices, usingTransport.REDISwith the Redis Transporter for pub/sub messaging between services. - Caching: Via
@nestjs/common’s CacheModule and CacheInterceptor, which provide a store-agnostic caching layer. Thecache-manager-redis-storeadapter connects this layer to Redis.
A third, manual approach uses ioredis directly in custom providers, without relying on NestJS abstractions.
Key imports
@nestjs/microservices—Transport,ClientProxy,MessagePattern,EventPattern,RedisContext@nestjs/common—CacheModule,CacheInterceptor,CacheKey,CacheTTL,CACHE_MANAGER