@voiceflow/nestjs-redis
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

NestJS Redis

Redis, but for NestJS

Installation

yarn add @voiceflow/nestjs-redis ioredis
yarn add -D @types/ioredis

Usage

The redis module can be setup in a couple different ways using forRootAsync:

  • A RedisOptions object can be provided via useValue.
  • A useFactory function can be provided to return a RedisOptions object (or a promise for one!).
  • A class implementing RedisOptions can be provided using useClass.
import { RedisModule, RedisService, RedisOptions } from '@voiceflow/nestjs-redis';

@Module({
  imports: [
    RedisModule.forRootAsync({
      imports: [],

      // Union field, one of `useValue`, `useFactory`, or `useClass`:
      useValue: {
        host: '0.0.0.0',
        port: 6379,
      },
      useFactory: () => getRedisConfig(),
      useClass: RedisConfigService,
    }),
  ],
})
export class AppModule {}

If you have an existing redis connection that you'd like to reuse, you can provide that in forRoot.

import IORedis from 'ioredis';

const redisConnection = new IORedis(...);

@Module({
  imports: [
    RedisModule.forRoot(redisConnection),
  ],
})
export class AppModule {}

Once the RedisModule is globally registered, RedisService can be injected in other providers without having to import RedisModule again.

Readme

Keywords

Package Sidebar

Install

npm i @voiceflow/nestjs-redis

Weekly Downloads

34

Version

1.3.0

License

ISC

Unpacked Size

17.5 kB

Total Files

20

Last publish

Collaborators

  • pmvrmc
  • matheuspoleza
  • amandasteinhauer
  • filipemerker
  • andrewlawrence
  • tylerhhan
  • effervescentia
  • josh_vf
  • voiceflow-gallagan
  • z4o4z
  • sssoflyyy
  • xavidop
  • vf-serviceaccount
  • zhilight
  • trs
  • viniciusdacal
  • ytolun
  • shelone.grantwatson
  • edison-vflow
  • sanasarjanjughazyan
  • ose-voiceflow
  • dandonovan78
  • gillyb
  • theprof
  • abuyak
  • matthewnaik
  • ninabondar
  • jbydeley