diff --git a/jit-binding-server/build.gradle.kts b/jit-binding-server/build.gradle.kts index 686b6e613..c3d85b4b6 100644 --- a/jit-binding-server/build.gradle.kts +++ b/jit-binding-server/build.gradle.kts @@ -18,8 +18,8 @@ dependencies { implementation("io.ktor:ktor-server-call-id") implementation("io.ktor:ktor-server-metrics-micrometer") implementation("io.micrometer:micrometer-registry-prometheus:1.14.4") - - implementation("io.github.reactivecircus.cache4k:cache4k:0.14.0") + + implementation("com.sksamuel.aedile:aedile-core:2.0.3") implementation("io.github.oshai:kotlin-logging:7.0.4") implementation(platform("org.apache.logging.log4j:log4j-bom:2.24.3")) implementation("org.apache.logging.log4j:log4j-jul") diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt index 851db1fff..9660352f4 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt @@ -1,7 +1,9 @@ package io.github.typesafegithub.workflows.jitbindingserver +import com.github.benmanes.caffeine.cache.Caffeine +import com.sksamuel.aedile.core.asCache +import com.sksamuel.aedile.core.expireAfterWrite import io.github.oshai.kotlinlogging.KotlinLogging.logger -import io.github.reactivecircus.cache4k.Cache import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords import io.github.typesafegithub.workflows.actionbindinggenerator.domain.prettyPrint import io.github.typesafegithub.workflows.mavenbinding.Artifact @@ -20,6 +22,7 @@ import io.ktor.server.routing.get import io.ktor.server.routing.head import io.ktor.server.routing.route import io.micrometer.core.instrument.Tag +import io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics import io.micrometer.prometheusmetrics.PrometheusMeterRegistry import kotlin.time.Duration.Companion.hours @@ -27,9 +30,16 @@ private val logger = logger { } typealias ArtifactResult = Result> -private val bindingsCache = Cache.Builder().expireAfterWrite(1.hours).build() +private val bindingsCache = + Caffeine + .newBuilder() + .expireAfterWrite(1.hours) + .recordStats() + .asCache() fun Routing.artifactRoutes(prometheusRegistry: PrometheusMeterRegistry) { + CaffeineCacheMetrics.monitor(prometheusRegistry, bindingsCache.underlying(), "bindings_cache") + route("{owner}/{name}/{version}/{file}") { artifact(prometheusRegistry, refresh = false) }