From e139550949a52ebfabc6de4307f4ea4d1595d82b Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sat, 27 Jun 2020 23:07:20 +0200 Subject: [PATCH] Make cache expiration configurable --- .../java/com/plotsquared/core/configuration/Settings.java | 7 +++++++ .../java/com/plotsquared/core/util/TabCompletions.java | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index 7b0196412..80d103882 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -527,6 +527,13 @@ public class Settings extends Config { public static int TARGET_TIME = 65; } + @Comment("Settings related to tab completion") + public static final class Tab_Completions { + @Comment({"The time in seconds how long tab completions should remain in cache.", + "0 will disable caching. Lower values may be less performant."}) + public static int CACHE_EXPIRATION = 15; + } + @Comment({"Enable or disable parts of the plugin", "Note: A cache will use some memory if enabled"}) diff --git a/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java b/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java index dbf053c52..56a3ff8fa 100644 --- a/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java +++ b/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java @@ -56,7 +56,9 @@ import java.util.stream.Collectors; public class TabCompletions { private final Cache> cachedCompletionValues = - CacheBuilder.newBuilder().expireAfterWrite(15, TimeUnit.SECONDS).build(); + CacheBuilder.newBuilder() + .expireAfterWrite(Settings.Tab_Completions.CACHE_EXPIRATION, TimeUnit.SECONDS) + .build(); private final Command booleanTrueCompletion = new Command(null, false, "true", "", RequiredType.NONE, null) {};