@goopen/nestjs-ioredis-provider
v1.1.1
Published
Tiny NestJS provider for ioredis
Downloads
920
Readme
NestJS provider for ioredis client and cluster
1. Install
npm install @goopen/nestjs-ioredis-provider ioredis
2. Register the provider
@Module({
imports: [
RedisModule.register({
url: redisUrl,
isGlobal: true,
}),
],
})
export class AppModule {}
3. You're then able to use the injector to use the Redis
@Injectable()
export class AppService{
constructor(
@InjectRedis() private readonly redisClient: Redis,
) {}
}
The library also provides a health indicator that can be used with terminus
1. Import health indicator
@Module({
imports: [TerminusModule],
providers: [HealthService, RedisHealthIndicator],
})
export class HealthModule {}
2. Use isHealthy
method from health indicator
@Injectable()
export class HealthService{
constructor(
private redis: RedisHealthIndicator,
) {}
pingRedis() {
return () => this.redis.isHealthy('redis');
}
}