From eb4a6eca63a5d3c0114e6ed99ba6f9e3a884d636 Mon Sep 17 00:00:00 2001 From: Slavcho Ivanov Date: Wed, 1 Nov 2023 22:00:08 +0200 Subject: [PATCH] Reduce the cache ttl for public donations and total money collected. The idea of the cache is to help in extreme scenarios when many requests are being fired. One request every 2 seconds should be easy to handle by the backend. --- apps/api/src/donations/donations.controller.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/api/src/donations/donations.controller.ts b/apps/api/src/donations/donations.controller.ts index 200733c51..fed254b41 100644 --- a/apps/api/src/donations/donations.controller.ts +++ b/apps/api/src/donations/donations.controller.ts @@ -30,7 +30,7 @@ import { DonationQueryDto } from '../common/dto/donation-query-dto' import { CancelPaymentIntentDto } from './dto/cancel-payment-intent.dto' import { DonationsApiQuery } from './queries/donations.apiquery' import { PersonService } from '../person/person.service' -import { CacheInterceptor } from '@nestjs/cache-manager' +import { CacheInterceptor, CacheTTL } from '@nestjs/cache-manager' import { UseInterceptors } from '@nestjs/common' @ApiTags('donation') @@ -111,6 +111,7 @@ export class DonationsController { } @Get('money') + @CacheTTL(5 * 1000) @UseInterceptors(CacheInterceptor) @Public() async totalDonatedMoney() { @@ -126,6 +127,7 @@ export class DonationsController { @Get('listPublic') @UseInterceptors(CacheInterceptor) + @CacheTTL(2 * 1000) @Public() @ApiQuery({ name: 'campaignId', required: false, type: String }) @ApiQuery({ name: 'status', required: false, enum: DonationStatus })