title: How should nestjs-redis be used correctly? Any example of nestjs-redis?
body: <p>When I used nestjs-redis recently, there is no official example, I don't know how to use it correctly.</p>
  <p>app.module.ts</p>
  <pre><code>import { Module } from '@nestjs/common';
  import { TypeOrmModule } from '@nestjs/typeorm';
  import { typeOrmConfig } from './config/typeorm.config';
  import { AuthModule } from './base/auth.module';
  import { RedisModule } from 'nestjs-redis';
  import { SmsService } from './common/providers/sms.service';
  import { redisConfig } from './config/redis.config';
  import { RedisClientService } from './common/providers/redis-client.service';
  
  @Module({
    imports: [
      TypeOrmModule.forRoot(typeOrmConfig),
      AuthModule,
      RedisModule.register(redisConfig),
    ],
    providers: [SmsService, RedisClientService],
  })
  export class AppModule {}
  
  </code></pre>
  <p>redis-client.service.ts</p>
  <pre><code>import { Injectable } from '@nestjs/common';
  import { RedisService } from 'nestjs-redis';
  import * as Redis from 'ioredis';
  
  @Injectable()
  export class RedisClientService {
    // I want to add a private variable.
    private _client
  
    constructor(
      private readonly redisService: RedisService,
    ) {
      this.getClient().then((client) =&gt; (this._client = client));
    }
  
    async getClient(): Promise&lt;Redis.Redis&gt; {
      const client = await this.redisService.getClient('main');
      return client;
    }
  
  
    async setValue(key: string, value: string, expiryMode: string|any, time: string|any) : Promise&lt;boolean&gt;{
      // use _client in this method
      // this._client.set() // this is correct?
      const client = await this.getClient();
      const result = await client.set(key, value, expiryMode, time);
      return result == 'OK';
    }
  }
  </code></pre>
  <p>My example above declares a variable <code>_client</code>, but I don’t know how to use it right?</p>