From 821f8a58bbcd4f22a58e11c752d2353db8d20ae9 Mon Sep 17 00:00:00 2001 From: Loup Theron Date: Tue, 14 Jan 2025 09:34:28 +0100 Subject: [PATCH] Add permanent ports caches --- .../cache/CaffeineConfiguration.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt index bd21d715ca..eac7b7c611 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt @@ -129,9 +129,9 @@ class CaffeineConfiguration { val missionControlUnitsCache = buildMinutesCache(missionControlUnits, ticker, 120) // Ports - val portsCache = buildMinutesCache(ports, ticker, oneWeek) - val activePortsCache = buildMinutesCache(activePorts, ticker, oneDay) - val portCache = buildMinutesCache(port, ticker, oneWeek) + val portsCache = buildPermanentCache(ports) + val activePortsCache = buildPermanentCache(activePorts) + val portCache = buildPermanentCache(port) // Risk Factors val riskFactorCache = buildMinutesCache(riskFactor, ticker, 1) @@ -245,6 +245,17 @@ class CaffeineConfiguration { ) } + private fun buildPermanentCache( + name: String, + ): CaffeineCache { + return CaffeineCache( + name, + Caffeine.newBuilder() + .recordStats() + .build(), + ) + } + private fun buildSecondsCache( name: String, ticker: Ticker,