0.1.0 • Published 4 years ago

nest-module-redis v0.1.0

Weekly downloads
21
License
MIT
Repository
github
Last release
4 years ago

Redis Dynamic Module for Nest.js

Note: this is a global module.

Installation

NPM

npm install --save nest-module-redis

Yarn

yarn add nest-module-redis

Usage

// app.module.ts
import { RedisModule } from 'nest-module-redis';
import { Module } from '@nestjs/common'

@Module({
    RedisModule.forRoot(options)
})
export class AppModule {}
// cat.service.ts
import { Injectable, Inject, forwardRef } from '@nestjs/common';
import { RedisClient, REDIS_CLIENT } from 'nest-module-redis';

@Injectable()
export class CatService {
    constructor(
    	@Inject(forwardRef(() => REDIS_CLIENT))
         private readonly redisClient: RedisClient,
    ) {}
    
    async get() {
        const result = await this.redisClient.get('key');
        return result;
    }
}

options: ioredis options

redisClient: A ioredis instance