Skip to content

chqrd/nest-redis

Repository files navigation

nest-redis

This NestJS module adds a Redis connection to your project.

Installation

import { RedisModule } from "@chqrd/nest-redis";
import { Module } from "@nestjs/common";

@Module({
  imports: [
    RedisModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: async (config) => ({ url: config.getOrThrow("REDIS_URL", "redis://localhost:6379") }),
    }),
  ],
})
export class AppModule {}
@Injectable()
export class RequestService {
  constructor(private readonly redis: RedisService) {}

  async getValue() {
    return await this.redis.client.get("my_key");
  }
}

Project setup

$ npm install

Compile and run the project

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

About

Redis-Client-Module for NestJS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages