1.0.7 • Published 5 years ago

@quickts/nestjs-redis v1.0.7

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

nestjs-redis

Installation

$ npm install @quickts/nestjs-redis ioredis
$ npm install -D @types/ioredis

Usage

// file: app.module.ts
import { Module } from "@nestjs/common";
import { RedisModule } from "@quickts/nestjs-redis";

@Module({
    imports: [RedisModule.forRoot({...})], // 注册模块
})
export class ApplicationModule {}

// file: other.ts
import { RedisClient, OnRedisClientInit } from "@quickts/nestjs-redis";
import { Redis } from "ioredis";

@Injectable()
class OtherService implements OnRedisClientInit {
    @RedisClient()// 方式一: 使用装饰器注入
    redis: Redis;

    onRedisClientInit(redis: Redis){
        this.redis = redis;// 方式二: 实现接口自行赋值
    }
}
1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago