|
@@ -1,8 +1,13 @@
|
|
-import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
|
|
|
|
|
|
+import {
|
|
|
|
+ Injectable,
|
|
|
|
+ Logger,
|
|
|
|
+ OnModuleDestroy,
|
|
|
|
+ OnModuleInit,
|
|
|
|
+} from '@nestjs/common';
|
|
import { RedisService } from 'nestjs-redis';
|
|
import { RedisService } from 'nestjs-redis';
|
|
|
|
|
|
@Injectable()
|
|
@Injectable()
|
|
-export class CacheService implements OnModuleInit {
|
|
|
|
|
|
+export class CacheService implements OnModuleInit, OnModuleDestroy {
|
|
public client;
|
|
public client;
|
|
private logger: Logger = new Logger('CacheService');
|
|
private logger: Logger = new Logger('CacheService');
|
|
constructor(private redisService: RedisService) {}
|
|
constructor(private redisService: RedisService) {}
|
|
@@ -16,6 +21,10 @@ export class CacheService implements OnModuleInit {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async onModuleDestroy() {
|
|
|
|
+ this.client = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
async getClient() {
|
|
async getClient() {
|
|
this.client = await this.redisService.getClient();
|
|
this.client = await this.redisService.getClient();
|
|
}
|
|
}
|