From 49f6b7708f297ab098ca7b6c3389911dd186fdcb Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Sat, 6 Feb 2021 08:12:42 +0200 Subject: [PATCH] Made update threshold configurable --- .../resolver/json/AsyncJSONResolverService.java | 6 +++--- .../plan/settings/config/paths/WebserverSettings.java | 6 ++++++ .../src/main/resources/assets/plan/bungeeconfig.yml | 11 +++++++++++ Plan/common/src/main/resources/assets/plan/config.yml | 11 +++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/AsyncJSONResolverService.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/AsyncJSONResolverService.java index bb8044214..fdaf14038 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/AsyncJSONResolverService.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/AsyncJSONResolverService.java @@ -19,6 +19,7 @@ package com.djrapitops.plan.delivery.webserver.resolver.json; import com.djrapitops.plan.delivery.webserver.cache.DataID; import com.djrapitops.plan.processing.Processing; import com.djrapitops.plan.settings.config.PlanConfig; +import com.djrapitops.plan.settings.config.paths.WebserverSettings; import com.djrapitops.plan.storage.json.JSONStorage; import com.djrapitops.plan.utilities.UnitSemaphoreAccessLock; @@ -30,7 +31,6 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.function.Supplier; @@ -74,7 +74,7 @@ public class AsyncJSONResolverService { } // No new enough version, let's refresh and send old version of the file - long updateThreshold = TimeUnit.MINUTES.toMillis(1L); // TODO make configurable + long updateThreshold = config.get(WebserverSettings.REDUCED_REFRESH_BARRIER); // Check if the json is already being created Future updatedJSON; @@ -125,7 +125,7 @@ public class AsyncJSONResolverService { } // No new enough version, let's refresh and send old version of the file - long updateThreshold = TimeUnit.MINUTES.toMillis(1L); // TODO make configurable + long updateThreshold = config.get(WebserverSettings.REDUCED_REFRESH_BARRIER); // Check if the json is already being created Future updatedJSON; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/WebserverSettings.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/WebserverSettings.java index 69da48763..f6c0ff74d 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/WebserverSettings.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/WebserverSettings.java @@ -43,6 +43,12 @@ public class WebserverSettings { public static final Setting DISABLED_AUTHENTICATION = new BooleanSetting("Webserver.Security.Disable_authentication"); public static final Setting EXTERNAL_LINK = new StringSetting("Webserver.External_Webserver_address"); + public static final Setting REDUCED_REFRESH_BARRIER = new TimeSetting("Webserver.Cache.Reduced_refresh_barrier"); + public static final Setting INVALIDATE_QUERY_RESULTS = new TimeSetting("Webserver.Cache.Invalidate_query_results_on_disk_after"); + public static final Setting INVALIDATE_DISK_CACHE = new TimeSetting("Webserver.Cache.Invalidate_disk_cache_after"); + public static final Setting INVALIDATE_MEMORY_CACHE = new TimeSetting("Webserver.Cache.Invalidate_memory_cache_after"); + public static final Setting INVALIDATE_FILE_CACHE = new TimeSetting("Webserver.Cache.Invalidate_file_cache_after"); + private WebserverSettings() { /* static variable class */ } diff --git a/Plan/common/src/main/resources/assets/plan/bungeeconfig.yml b/Plan/common/src/main/resources/assets/plan/bungeeconfig.yml index ada9ace1d..6cb40d727 100644 --- a/Plan/common/src/main/resources/assets/plan/bungeeconfig.yml +++ b/Plan/common/src/main/resources/assets/plan/bungeeconfig.yml @@ -44,6 +44,17 @@ Webserver: # InternalIP usually does not need to be changed, only change it if you know what you're doing! # 0.0.0.0 allocates Internal (local) IP automatically for the WebServer. Internal_IP: 0.0.0.0 + Cache: + Reduced_refresh_barrier: 1 + Unit: MINUTES + Invalidate_query_results_on_disk_after: 7 + Unit: DAYS + Invalidate_disk_cache_after: 1 + Unit: DAYS + Invalidate_memory_cache_after: 5 + Unit: MINUTES + Invalidate_file_cache_after: 10 + Unit: MINUTES Security: SSL_certificate: KeyStore_path: Cert.jks diff --git a/Plan/common/src/main/resources/assets/plan/config.yml b/Plan/common/src/main/resources/assets/plan/config.yml index 3f22bf50c..c667d0d9e 100644 --- a/Plan/common/src/main/resources/assets/plan/config.yml +++ b/Plan/common/src/main/resources/assets/plan/config.yml @@ -49,6 +49,17 @@ Webserver: # InternalIP usually does not need to be changed, only change it if you know what you're doing! # 0.0.0.0 allocates Internal (local) IP automatically for the WebServer. Internal_IP: 0.0.0.0 + Cache: + Reduced_refresh_barrier: 1 + Unit: MINUTES + Invalidate_query_results_on_disk_after: 7 + Unit: DAYS + Invalidate_disk_cache_after: 1 + Unit: DAYS + Invalidate_memory_cache_after: 5 + Unit: MINUTES + Invalidate_file_cache_after: 10 + Unit: MINUTES Security: SSL_certificate: KeyStore_path: Cert.jks