app/api: add feature to disable cache for some queries

This commit is contained in:
vchikalkin 2024-02-18 15:15:53 +03:00
parent 4bc5234d09
commit e0d2836f4a
2 changed files with 5 additions and 5 deletions

View File

@ -1,3 +1,4 @@
export const queryTTL: Record<string, number> = {
export const queryTTL: Record<string, number | false> = {
GetLeads: false,
GetSystemUser: 6 * 60 * 60,
};

View File

@ -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);
}