Trying async cache for DelegatedExpressionHandler

This commit is contained in:
Will FP
2024-12-05 16:31:30 +00:00
parent 2158be40cd
commit d87fcc96bb

View File

@@ -12,7 +12,8 @@ class DelegatedExpressionHandler(
) : ExpressionHandler { ) : ExpressionHandler {
private val evaluationCache: Cache<Int, Double?> = Caffeine.newBuilder() private val evaluationCache: Cache<Int, Double?> = Caffeine.newBuilder()
.expireAfterWrite(plugin.configYml.getInt("math-cache-ttl").toLong(), TimeUnit.MILLISECONDS) .expireAfterWrite(plugin.configYml.getInt("math-cache-ttl").toLong(), TimeUnit.MILLISECONDS)
.build() .buildAsync<Int, Double?>()
.synchronous()
override fun evaluate(expression: String, context: PlaceholderContext): Double? { override fun evaluate(expression: String, context: PlaceholderContext): Double? {
expression.fastToDoubleOrNull()?.let { return it } expression.fastToDoubleOrNull()?.let { return it }