nest-module-redis
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i nest-module-redis

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

6.18 kB

Total Files

19

Last publish

Collaborators

  • neail