Skip to content

Commit

Permalink
Added ability to configure literal cache ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
0ft3n committed Jan 22, 2024
1 parent e0f631b commit 74a8dce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion eco-api/src/main/java/com/willfp/eco/util/PatternUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.willfp.eco.core.Eco;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.TimeUnit;
Expand All @@ -15,7 +16,7 @@ public final class PatternUtils {
* Cache of compiled literal patterns.
*/
private static final Cache<String, Pattern> LITERAL_PATTERN_CACHE = Caffeine.newBuilder()
.expireAfterAccess(15, TimeUnit.MINUTES)
.expireAfterAccess(Eco.get().getEcoPlugin().getConfigYml().getInt(""), TimeUnit.MINUTES)
.build();

/**
Expand Down
5 changes: 5 additions & 0 deletions eco-core/core-plugin/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ use-immediate-placeholder-translation-for-math: false
# less reactive values.
math-cache-ttl: 200

# The time (in minutes) for literal patterns to be cached for. Higher values will lead to
# faster evaluation times (less CPU usage) at the expense of slightly more memory usage and
# less reactive values. (Do not change unless you are told to).
literal-cache-ttl: 1

# If anonymous usage statistics should be tracked. This is very valuable information as it
# helps understand how eco and other plugins are being used by logging player and server
# counts. This is completely anonymous and no personal information is logged. This data
Expand Down

0 comments on commit 74a8dce

Please sign in to comment.