1.2.0 • Published 8 months ago
@goopen/nestjs-ioredis-provider v1.2.0
NestJS provider for ioredis client and cluster
1. Install
npm install @goopen/nestjs-ioredis-provider ioredis2. 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');
}
}