nest-module-redis
v0.1.0
Published
A nestjs redis dynamic module
Downloads
3
Readme
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