Registry / database / nestjs-redis-client

nestjs-redis-client

JSON →
library1.0.12jsnpmunverified

A configurable NestJS module for Redis integration built on ioredis. Version 1.0.12 is stable and supports NestJS versions 9, 10, and 11. It provides a RedisService with comprehensive Redis commands, static and async configuration via register/registerAsync, global module support, and a built-in caching interceptor for automatic method response caching with customizable TTL. Key differentiators include type safety (TypeScript types shipped), simplicity of setup, and the interceptor feature that reduces boilerplate for caching.

npm install nestjs-redis-client
INSTALL
IMPORT
SIG · NESTJS-REDIS-CLIEN
N
nestjs-redis-client
databasejavascriptv1.0.12
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-client'
Named export; ESM only.
RedisService
import { RedisService } from 'nestjs-redis-client'
import RedisService from 'nestjs-redis-client'
Named export, not default.
RedisModule.registerAsync
RedisModule.registerAsync({...})
RedisModule.forRootAsync({...})
Use registerAsync, not forRootAsync.
RedisModule.register
RedisModule.register({...})
RedisModule.forRoot({...})
Use register, not forRoot.

Shows how to import RedisModule, configure it statically with global scope, and use RedisService to set and get a key with TTL.

import { Module } from '@nestjs/common'; import { RedisModule } from 'nestjs-redis-client'; @Module({ imports: [ RedisModule.register({ host: 'localhost', port: 6379, isGlobal: true, }), ], }) export class AppModule {} // In a service: import { Injectable } from '@nestjs/common'; import { RedisService } from 'nestjs-redis-client'; @Injectable() export class MyService { constructor(private readonly redisService: RedisService) {} async setAndGet() { await this.redisService.set('key', 'value', 3600); return this.redisService.get<string>('key'); } }
Debug
Known issues
gotchaInterceptor requires module-level configuration; using RedisCacheInterceptor without proper setup may cause runtime errors.
fix
Ensure RedisModule is imported with appropriate config and the interceptor is applied correctly via @UseInterceptors.
affects: >=1.0.0
gotchaThe module expects @nestjs/common and @nestjs/core as peer dependencies; version mismatches can cause import errors.
fix
Install compatible versions: 'npm install @nestjs/common@^10 @nestjs/core@^10' (adjust to your NestJS version).
affects: 1.0.0-1.0.12
deprecatedNo known deprecations yet, but ioredis options may change in future releases.
fix
Stay updated with changelog; ioredis v5 deprecated certain options like retryStrategy.
affects: >=1.0.0
gotchaThe package uses ioredis internally; RedisService methods are not awaitable if you forget to use promises (ioredis supports both callback and promise).
fix
Always use async/await or .then() when calling RedisService methods.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'nestjs-redis-client' or its corresponding type declarations.
Missing installation or TypeScript cannot resolve the package.
fix
Run 'npm install nestjs-redis-client' and ensure tsconfig.json includes node_modules in types or skipLibCheck.
Nest cannot export a provider/module that is not a provider/module. Please double check the method signature.
Using forRoot() or forRootAsync() instead of register()/registerAsync().
fix
Use RedisModule.register({...}) or RedisModule.registerAsync({...}) in imports.
Property 'get' does not exist on type 'RedisService'.
Incorrect import or old version without that method.
fix
Use import { RedisService } from 'nestjs-redis-client' and check the documentation for available methods; update to latest version.
Invalid async configuration: useFactory must return an object with Redis options.
Factory function does not return valid ioredis options.
fix
Ensure useFactory returns an object like { host: '...', port: 6379 }.
Upgrade
Version history
1.0.12latest on npm
Audit
Dependencies
@nestjs/commonrequiredPeer dependency required for decorators and module utilities
@nestjs/corerequiredPeer dependency required for NestJS core functionality
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
nestjs-redis-client — npm install nestjs-redis-client · libregistry