From 2a9e705800363bcc8a8d3937de99d1852d974af9 Mon Sep 17 00:00:00 2001 From: Deivison Lincoln Date: Tue, 27 Aug 2024 11:26:33 -0300 Subject: [PATCH] =?UTF-8?q?Resolve=20Erros=20=20no=20cacheService=20caso?= =?UTF-8?q?=20REDIS=20n=C3=A3o=20esteja=20habilitado.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/services/cache.service.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/api/services/cache.service.ts b/src/api/services/cache.service.ts index a160b1d2..0feffc2b 100644 --- a/src/api/services/cache.service.ts +++ b/src/api/services/cache.service.ts @@ -17,10 +17,15 @@ export class CacheService { if (!this.cache) { return; } + return this.cache.get(key); } public async hGet(key: string, field: string) { + if (!this.cache) { + return false; + } + try { const data = await this.cache.hGet(key, field); @@ -39,10 +44,15 @@ export class CacheService { if (!this.cache) { return; } + this.cache.set(key, value); } public async hSet(key: string, field: string, value: any) { + if (!this.cache) { + return false; + } + try { const json = JSON.stringify(value, BufferJSON.replacer); @@ -56,6 +66,7 @@ export class CacheService { if (!this.cache) { return; } + return this.cache.has(key); } @@ -63,10 +74,15 @@ export class CacheService { if (!this.cache) { return; } + return this.cache.delete(key); } async hDelete(key: string, field: string) { + if (!this.cache) { + return false; + } + try { await this.cache.hDelete(key, field); return true; @@ -80,6 +96,7 @@ export class CacheService { if (!this.cache) { return; } + return this.cache.deleteAll(appendCriteria); } @@ -87,6 +104,7 @@ export class CacheService { if (!this.cache) { return; } + return this.cache.keys(appendCriteria); } }