From 0f15cd7230e75a9a17a6386849760653fd9c6a0b Mon Sep 17 00:00:00 2001 From: Brutus5000 Date: Wed, 1 Sep 2021 23:40:23 +0200 Subject: [PATCH] Add short-lived cache for game results --- src/main/java/com/faforever/api/config/CacheConfig.java | 2 ++ src/main/java/com/faforever/api/data/domain/Game.java | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/faforever/api/config/CacheConfig.java b/src/main/java/com/faforever/api/config/CacheConfig.java index dec08350e..49b5fd634 100644 --- a/src/main/java/com/faforever/api/config/CacheConfig.java +++ b/src/main/java/com/faforever/api/config/CacheConfig.java @@ -8,6 +8,7 @@ import com.faforever.api.data.domain.CoopResult; import com.faforever.api.data.domain.Event; import com.faforever.api.data.domain.FeaturedMod; +import com.faforever.api.data.domain.Game; import com.faforever.api.data.domain.Leaderboard; import com.faforever.api.data.domain.LeaderboardRating; import com.faforever.api.data.domain.Map; @@ -57,6 +58,7 @@ public CacheManager cacheManager() { new CaffeineCache(CoopResult.TYPE_NAME, newBuilder().expireAfterWrite(5, MINUTES).build()), new CaffeineCache(Event.TYPE_NAME, newBuilder().expireAfterWrite(60, MINUTES).build()), new CaffeineCache(FeaturedMod.TYPE_NAME, newBuilder().expireAfterWrite(60, MINUTES).build()), + new CaffeineCache(Game.TYPE_NAME, newBuilder().expireAfterWrite(1, MINUTES).build()), new CaffeineCache(Map.TYPE_NAME, newBuilder().expireAfterWrite(60, MINUTES).build()), new CaffeineCache(MapVersion.TYPE_NAME, newBuilder().expireAfterWrite(60, MINUTES).build()), new CaffeineCache(MapStatistics.TYPE_NAME, newBuilder().expireAfterWrite(1, MINUTES).build()), diff --git a/src/main/java/com/faforever/api/data/domain/Game.java b/src/main/java/com/faforever/api/data/domain/Game.java index 995fee834..e3d6f563d 100644 --- a/src/main/java/com/faforever/api/data/domain/Game.java +++ b/src/main/java/com/faforever/api/data/domain/Game.java @@ -29,13 +29,16 @@ import java.time.OffsetDateTime; import java.util.Set; +import static com.faforever.api.data.domain.Game.TYPE_NAME; + @Entity @Table(name = "game_stats") -@Include(name = "game") +@Include(name = TYPE_NAME) @Immutable @Setter @EntityListeners(GameEnricher.class) public class Game { + public final static String TYPE_NAME = "game"; private int id; private OffsetDateTime startTime;