11import { createClient , RedisClientType } from '@redis/client' ;
2- import { Logger } from '../config/logger.config' ;
32import { BufferJSON } from '@whiskeysockets/baileys' ;
3+
44import { Redis } from '../config/env.config' ;
5+ import { Logger } from '../config/logger.config' ;
56
67export class RedisCache {
78 constructor ( ) {
@@ -59,11 +60,7 @@ export class RedisCache {
5960 this . logger . verbose ( 'writeData: ' + field ) ;
6061 const json = JSON . stringify ( data , BufferJSON . replacer ) ;
6162
62- return await this . client . hSet (
63- this . redisEnv . PREFIX_KEY + ':' + this . instanceName ,
64- field ,
65- json ,
66- ) ;
63+ return await this . client . hSet ( this . redisEnv . PREFIX_KEY + ':' + this . instanceName , field , json ) ;
6764 } catch ( error ) {
6865 this . logger . error ( error ) ;
6966 }
@@ -72,10 +69,7 @@ export class RedisCache {
7269 public async readData ( field : string ) {
7370 try {
7471 this . logger . verbose ( 'readData: ' + field ) ;
75- const data = await this . client . hGet (
76- this . redisEnv . PREFIX_KEY + ':' + this . instanceName ,
77- field ,
78- ) ;
72+ const data = await this . client . hGet ( this . redisEnv . PREFIX_KEY + ':' + this . instanceName , field ) ;
7973
8074 if ( data ) {
8175 this . logger . verbose ( 'readData: ' + field + ' success' ) ;
@@ -92,10 +86,7 @@ export class RedisCache {
9286 public async removeData ( field : string ) {
9387 try {
9488 this . logger . verbose ( 'removeData: ' + field ) ;
95- return await this . client . hDel (
96- this . redisEnv . PREFIX_KEY + ':' + this . instanceName ,
97- field ,
98- ) ;
89+ return await this . client . hDel ( this . redisEnv . PREFIX_KEY + ':' + this . instanceName , field ) ;
9990 } catch ( error ) {
10091 this . logger . error ( error ) ;
10192 }
@@ -104,9 +95,7 @@ export class RedisCache {
10495 public async delAll ( hash ?: string ) {
10596 try {
10697 this . logger . verbose ( 'instance delAll: ' + hash ) ;
107- const result = await this . client . del (
108- hash || this . redisEnv . PREFIX_KEY + ':' + this . instanceName ,
109- ) ;
98+ const result = await this . client . del ( hash || this . redisEnv . PREFIX_KEY + ':' + this . instanceName ) ;
11099
111100 return result ;
112101 } catch ( error ) {
0 commit comments