From e0d2836f4ac6a4704a0f4067a6c9bc62909bd6a0 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Sun, 18 Feb 2024 15:15:53 +0300 Subject: [PATCH] app/api: add feature to disable cache for some queries --- apps/api/src/proxy/lib/config.ts | 3 ++- apps/api/src/proxy/proxy.controller.ts | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/api/src/proxy/lib/config.ts b/apps/api/src/proxy/lib/config.ts index 8289031..280f745 100644 --- a/apps/api/src/proxy/lib/config.ts +++ b/apps/api/src/proxy/lib/config.ts @@ -1,3 +1,4 @@ -export const queryTTL: Record = { +export const queryTTL: Record = { + GetLeads: false, GetSystemUser: 6 * 60 * 60, }; diff --git a/apps/api/src/proxy/proxy.controller.ts b/apps/api/src/proxy/proxy.controller.ts index e58dd21..afc5790 100644 --- a/apps/api/src/proxy/proxy.controller.ts +++ b/apps/api/src/proxy/proxy.controller.ts @@ -31,10 +31,9 @@ export class ProxyController { }); const data = await response.json(); - if (data) { - const ttl = queryTTL[operationName] || env.CACHE_TTL; - await this.cacheManager.set(key, data, { ttl }); - } + const ttl = queryTTL[operationName]; + if (data && ttl !== false) + await this.cacheManager.set(key, data, { ttl: ttl || env.CACHE_TTL }); return reply.send(data); }