|
@@ -10,7 +10,7 @@ import { RedisService } from 'nestjs-redis';
|
|
|
export class CacheService implements OnModuleInit, OnModuleDestroy {
|
|
|
public client;
|
|
|
private logger: Logger = new Logger('CacheService');
|
|
|
- constructor(private redisService: RedisService) {}
|
|
|
+ constructor(private redisService: RedisService) { }
|
|
|
|
|
|
async onModuleInit() {
|
|
|
try {
|
|
@@ -84,6 +84,18 @@ export class CacheService implements OnModuleInit, OnModuleDestroy {
|
|
|
}
|
|
|
await this.client.del(key);
|
|
|
}
|
|
|
+ public async hDel(key: string, data: any) {
|
|
|
+ if (!this.client) {
|
|
|
+ await this.getClient();
|
|
|
+ }
|
|
|
+ return this.client.hdel(key, data);
|
|
|
+ }
|
|
|
+ public async hSet(key: string, data: any, value: any) {
|
|
|
+ if (!this.client) {
|
|
|
+ await this.getClient();
|
|
|
+ }
|
|
|
+ return this.client.hset(key, data, value);
|
|
|
+ }
|
|
|
// 清理缓存
|
|
|
public async flushall(): Promise<any> {
|
|
|
if (!this.client) {
|