mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
Merge pull request #838 from judsonjuniorr/v2-fix-cache-errors
Validate if cache exists before accessing it
This commit is contained in:
commit
256bd3ef73
@ -21,6 +21,9 @@ export class CacheService {
|
||||
}
|
||||
|
||||
public async hGet(key: string, field: string) {
|
||||
if (!this.cache) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const data = await this.cache.hGet(key, field);
|
||||
|
||||
@ -43,6 +46,9 @@ export class CacheService {
|
||||
}
|
||||
|
||||
public async hSet(key: string, field: string, value: any) {
|
||||
if (!this.cache) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const json = JSON.stringify(value, BufferJSON.replacer);
|
||||
|
||||
@ -67,6 +73,9 @@ export class CacheService {
|
||||
}
|
||||
|
||||
async hDelete(key: string, field: string) {
|
||||
if (!this.cache) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
await this.cache.hDelete(key, field);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user