connector name caching

This commit is contained in:
simonredfern 2025-11-24 12:58:47 +01:00
parent 91b31f1559
commit f57e422e2d

View File

@ -35,7 +35,6 @@ import com.github.dwickern.macros.NameOf.nameOf
import com.openbankproject.commons.ExecutionContext.Implicits.global
import com.openbankproject.commons.model.{CustomerAttribute, _}
import com.openbankproject.commons.util.{ApiVersion, ScannedApiVersion}
import com.tesobe.CacheKeyFromArguments
import net.liftweb.common.{Empty, Full}
import net.liftweb.http.provider.HTTPParam
import net.liftweb.http.rest.RestHelper
@ -1184,17 +1183,14 @@ trait APIMethods600 {
// Fetch connector method names with caching
methodNames <- Future {
/**
* Cache key will be auto-generated by macro.
* Connector methods rarely change (only on deployment), so we cache for a long time.
*/
var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
val cacheKey = "getConnectorMethodNames"
val cacheTTL = APIUtil.getPropsAsIntValue("getConnectorMethodNames.cache.ttl.seconds", 3600)
CacheKeyFromArguments.buildCacheKey {
Caching.memoizeSyncWithProvider(Some(cacheKey.toString()))(cacheTTL seconds) {
val connectorName = APIUtil.getPropsValue("connector", "mapped")
val connector = code.bankconnectors.Connector.getConnectorInstance(connectorName)
connector.callableMethods.keys.toList
}
Caching.memoizeSyncWithProvider(Some(cacheKey))(cacheTTL seconds) {
val connectorName = APIUtil.getPropsValue("connector", "mapped")
val connector = code.bankconnectors.Connector.getConnectorInstance(connectorName)
connector.callableMethods.keys.toList
}
}
} yield {