From 7c745cf04d665bd953c13621f2fdb7af51e3ddc8 Mon Sep 17 00:00:00 2001 From: Gianlu Date: Fri, 10 Jul 2020 13:57:03 +0200 Subject: [PATCH] Cache JSON decks for longer --- .../cah/customsets/CustomCardsService.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java b/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java index 590e7c7..10d84e1 100644 --- a/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java +++ b/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java @@ -67,9 +67,14 @@ public class CustomCardsService { private static final long INVALID_SET_CACHE_LIFETIME = TimeUnit.SECONDS.toMillis(30); /** - * How long to cache valid card sets. + * How long to cache valid card sets added by URL. */ - private static final long VALID_SET_CACHE_LIFETIME = TimeUnit.MINUTES.toMillis(15); + private static final long VALID_SET_CACHE_LIFETIME_URL = TimeUnit.MINUTES.toMillis(15); + + /** + * How long to cache valid card sets added by JSON. + */ + private static final long VALID_SET_CACHE_LIFETIME_JSON = TimeUnit.HOURS.toMillis(12); private static final AtomicInteger cardIdCounter = new AtomicInteger(Integer.MIN_VALUE); private static final AtomicInteger deckIdCounter = new AtomicInteger(0); @@ -196,7 +201,7 @@ public class CustomCardsService { } } - putCache(deck, VALID_SET_CACHE_LIFETIME, url, hash); + putCache(deck, url == null ? VALID_SET_CACHE_LIFETIME_JSON : VALID_SET_CACHE_LIFETIME_URL, url, hash); return deck; } catch (Exception e) { putCache(null, INVALID_SET_CACHE_LIFETIME, url, hash);