Registry / database / nestjs-redis-cluster

nestjs-redis-cluster

JSON →
library2.1.0jsnpmunverified

A NestJS module for integrating Redis with cluster support, based on ioredis. Current stable version is 2.1.0. It provides RedisModule and RedisService to inject Redis clients into NestJS applications, supporting multiple named clients, async configuration, and custom error handlers. Released under MIT. Differentiates from other NestJS Redis libraries by offering explicit cluster support and straightforward registration patterns, though it requires careful handling of peer dependencies and module configuration.

npm install nestjs-redis-cluster
INSTALL
IMPORT
SIG · NESTJS-REDIS-CLUST
N
nestjs-redis-cluster
databasejavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RedisModule
import { RedisModule } from 'nestjs-redis-cluster'
import { RedisModule } from 'nestjs-redis'
Do not confuse with other packages; use the full package name.
RedisService
import { RedisService } from 'nestjs-redis-cluster'
import { RedisService } from '@nestjs/redis'
The service is part of this package, not from NestJS core.
RedisOptions
import { RedisOptions } from 'nestjs-redis-cluster'
interface RedisOptions { ... }
Type is exported; define inline if not imported.

Shows how to register RedisModule synchronously with basic options.

import { Module } from '@nestjs/common'; import { RedisModule } from 'nestjs-redis-cluster'; const redisOptions = { host: process.env.REDIS_HOST ?? 'localhost', port: parseInt(process.env.REDIS_PORT ?? '6379'), password: process.env.REDIS_PASSWORD ?? '', }; @Module({ imports: [RedisModule.register(redisOptions)], }) export class AppModule {}
Debug
Known issues
breakingioredis 4.x is required; ioredis 5.x is not compatible.
fix
Install ioredis@4.x as a dependency.
affects: >=2.0.0
gotchaThe module configuration must include a 'name' property when using multiple clients, otherwise it uses a UUID.
fix
Define a 'name' for each client when using multi-client setup.
affects: >=1.0.0
deprecatedRedisModule.forRootAsync is considered deprecated in favor of RedisModule.registerAsync.
fix
Use RedisModule.registerAsync method instead.
affects: >=2.0.0
gotchaThe 'onClientReady' option receives the ioredis client, but errors emitted after readiness may be missed if no listener is attached.
fix
Ensure 'onClientReady' attaches an error listener.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'nestjs-redis-cluster' or its corresponding type declarations.
Package not installed or missing peer dependencies.
fix
Run npm install nestjs-redis-cluster ioredis@4.x @nestjs/core @nestjs/common rxjs uuid
RedisClient is not a constructor
Incorrect ioredis version (v5 instead of v4).
fix
Install ioredis@4.x: npm install ioredis@4
RedisModule.register is not a function
Module imported incorrectly (e.g., default import vs named).
fix
Use named import: import { RedisModule } from 'nestjs-redis-cluster'
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
@nestjs/corerequiredRequired for NestJS module metadata and DI.
@nestjs/commonrequiredRequired for NestJS decorators and utilities.
ioredisrequiredRedis client library used for cluster connections.
rxjsrequiredPeer dependency for reactive programming patterns.
uuidrequiredPeer dependency used for generating unique client names.
Agent activity
4 hits · last 30 days
node
4
Resources
nestjs-redis-cluster — npm install nestjs-redis-cluster · libregistry