1.0.1 • Published 4 years ago

@jianghohwason/nt-addon-ioredis v1.0.1

Weekly downloads
2
License
Apache-2.0
Repository
-
Last release
4 years ago

nt-addon-redis

Redis addon for Notadd.

Installation

# install
$ npm install @jianghohwason/nt-addon-ioredis

or

$ yarn add @jianghohwason/nt-addon-ioredis

Usage

app.module.ts

import { Module } from '@nestjs/common';
import { RedisAddon } from '@jianghohwason/nt-addon-ioredis'

@Module({
    import: [
        RedisAddon.forRoot({
            // redis connection options, such as host, port, etc
        })
    ]
})
export AppModule { }

xxx.service.ts

import { Injectable } from '@nestjs/common';
import { RedisService } from '@jianghohwason/nt-addon-ioredis';

@Injectable()
export class TestService {
    constructor(
        @Inject(RedisService) private readonly redisService: RedisService
    ) { }

    // service method usage
    async test() {
        // redis hset
        await this.redisService.hset(key, field, value);
        // redis hget
        await this.redisService.hget(key, field);
    }
}