Plugin Architecture
Modular design — import only the features you need. Each plugin is self-contained with its own providers and exports.
Caching, distributed locks, rate limiting, and observability — with modular plugin architecture
NestJS RedisX provides comprehensive Redis integration for NestJS applications. It implements well-known patterns for caching, locking, and rate limiting with a focus on correctness and developer experience.
The NestJS ecosystem offers several Redis integration options. This table helps you understand where RedisX fits.
| RedisX | @nestjs/cache-manager | @liaoliaots/nestjs-redis | @nestjs-redis/kit | ioredis | |
|---|---|---|---|---|---|
| Type | Plugin Framework | Cache Module | Client Wrapper | Integrations Bundle | Client Library |
| Underlying Client | ioredis / node-redis | cache-manager | ioredis | node-redis | — |
| Actively Maintained | ✓ | ✓ | ✓ | ✓ | Best-effort |
| Infrastructure | |||||
| Cluster / Sentinel | ✓ | — | ✓ | ✓ | ✓ |
| Multiple Connections | ✓ | — | ✓ | ✓ | Manual |
| Health Checks | ✓ | — | ✓ | ✓ | Manual |
| Caching | |||||
| Basic Cache | ✓ | ✓ | Manual | Manual | Manual |
| L1 + L2 (Memory + Redis) | ✓ | — | — | — | — |
| Stampede Protection | ✓ | — | — | — | — |
| Stale-While-Revalidate | ✓ | — | — | — | — |
| Tag-based Invalidation | ✓ | — | — | — | — |
| Enterprise Patterns | |||||
| Distributed Locks | ✓ | — | — | ✓ | Manual |
| Lock Auto-renewal | ✓ | — | — | — | — |
| Rate Limiting | ✓ | — | — | ~¹ | — |
| Request Idempotency | ✓ | — | — | — | — |
| Streams + Consumer Groups | ✓ | — | — | — | Manual |
| Observability | |||||
| Prometheus Metrics | ✓ | — | — | — | — |
| OpenTelemetry Tracing | ✓ | — | — | — | — |
¹ Throttler storage adapter only — not standalone rate limiting with multiple algorithms
import { Module } from '@nestjs/common';
import { RedisModule } from '@nestjs-redisx/core';
import { CachePlugin } from '@nestjs-redisx/cache';
@Module({
imports: [
RedisModule.forRoot({
clients: {
host: 'localhost',
port: 6379,
},
plugins: [
new CachePlugin({
l1: { maxSize: 1000 },
l2: { defaultTtl: 3600 },
}),
],
}),
],
})
export class AppModule {}import { Injectable } from '@nestjs/common';
import { Cached } from '@nestjs-redisx/cache';
@Injectable()
export class UserService {
@Cached({ key: 'user:{0}', ttl: 300 })
async getUser(id: string): Promise<User> {
return this.userRepository.findById(id);
}
}The foundation of NestJS RedisX providing:
| Plugin | Version | Description |
|---|---|---|
| Cache | 1.0.0 | Two-tier caching with SWR, stampede protection, and tag invalidation |
| Locks | 1.0.0 | Distributed locks with auto-renewal and retry strategies |
| Rate Limit | 1.0.0 | Fixed window, sliding window, and token bucket algorithms |
| Idempotency | 1.0.0 | Request deduplication with fingerprinting and response replay |
| Streams | 1.0.0 | Redis Streams with consumer groups and dead letter queues |
| Metrics | 1.0.0 | Prometheus metrics export with Grafana dashboards |
| Tracing | 1.0.0 | OpenTelemetry distributed tracing integration |
NestJS RedisX is free and open source. If it saves your team time, consider sponsoring the project.