Skip to content

Commit

Permalink
Reduce the cache ttl for public donations and total money collected. (p…
Browse files Browse the repository at this point in the history
…odkrepi-bg#572)

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.
  • Loading branch information
slavcho authored Nov 2, 2023
1 parent 110443f commit d385420
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/api/src/donations/donations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -111,6 +111,7 @@ export class DonationsController {
}

@Get('money')
@CacheTTL(5 * 1000)
@UseInterceptors(CacheInterceptor)
@Public()
async totalDonatedMoney() {
Expand All @@ -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 })
Expand Down

0 comments on commit d385420

Please sign in to comment.