Skip to content

Commit

Permalink
increased ttl to relax #482
Browse files Browse the repository at this point in the history
  • Loading branch information
fcaps authored and Brutus5000 committed Nov 21, 2023
1 parent 429bdf6 commit 58517b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/LeaderboardService.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const leaderboardTTL = 60 * 60 * 4 // 4 hours ttl as a relaxation for https://github.com/FAForever/website/issues/482

class LeaderboardService {
constructor(cacheService, mutexService, leaderboardRepository, lockTimeout = 3000) {
this.lockTimeout = lockTimeout
Expand Down Expand Up @@ -26,7 +28,7 @@ class LeaderboardService {

await this.mutexService.acquire(async () => {
const result = await this.leaderboardRepository.fetchLeaderboard(id)
this.cacheService.set(cacheKey, result);
this.cacheService.set(cacheKey, result, leaderboardTTL);
})

return this.getLeaderboard(id)
Expand Down
2 changes: 1 addition & 1 deletion tests/LeaderboardService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test('full scenario', async () => {
expect(cacheSetSpy).toHaveBeenCalledTimes(1);

const date = new Date()
date.setSeconds(date.getSeconds() + 301)
date.setSeconds(date.getSeconds() + (60 * 60 * 4) + 1)
jest.setSystemTime(date);

// start another with when the cache is stale
Expand Down

0 comments on commit 58517b7

Please sign in to comment.