From 4aa64ca596478de8248c2e3f78a91d39cfeb687a Mon Sep 17 00:00:00 2001 From: Mikhail Deriabin Date: Tue, 20 May 2025 15:27:35 +0300 Subject: [PATCH] set time to live for leaderboards to 3h It is a temporary solution, which should resolve the problem that some of the player or clan data can be updated in the DB, but not in the leaderboard. With shorter TTL, it should be ok for now. Later possibly some other mechanism will be required --- src/leaderboard/leaderboard.service.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/leaderboard/leaderboard.service.ts b/src/leaderboard/leaderboard.service.ts index 6809f8b46..22cc22354 100644 --- a/src/leaderboard/leaderboard.service.ts +++ b/src/leaderboard/leaderboard.service.ts @@ -17,6 +17,11 @@ export class LeaderboardService { private readonly clanService: ClanService, ) {} + /** + * Leaderboard data update interval in second, 3h + */ + private readonly LEADERBOARD_TTL_S = 10800; + /** * Retrieves the clan leaderboard data. * @@ -73,7 +78,11 @@ export class LeaderboardService { data = await this.processCacheData(model, fetchedData); // Set the data with 12 hour ttl. The { ttl: number } as any is required to overwrite the default value. - await this.redisService.set(cacheKey, JSON.stringify(data), 60 * 60 * 12); + await this.redisService.set( + cacheKey, + JSON.stringify(data), + this.LEADERBOARD_TTL_S, + ); } if (reqQuery) {