Make cache expiration configurable

This commit is contained in:
Hannes Greule 2020-06-27 23:07:20 +02:00
parent 181c5b134f
commit e139550949
2 changed files with 10 additions and 1 deletions

View File

@ -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"})

View File

@ -56,7 +56,9 @@ import java.util.stream.Collectors;
public class TabCompletions {
private final Cache<String, List<String>> 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) {};