Merge pull request #2348 from hongwei1/develop

bugfix/move the future out of the cache
This commit is contained in:
Simon Redfern 2023-12-06 16:05:55 +01:00 committed by GitHub
commit 03a4f39b23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -3056,7 +3056,7 @@ object NewStyle extends MdcLoggable{
private[this] val endpointMappingTTL = APIUtil.getPropsValue(s"endpointMapping.cache.ttl.seconds", "0").toInt
def getEndpointMappings(bankId: Option[String], callContext: Option[CallContext]): OBPReturnType[List[EndpointMappingT]] = {
def getEndpointMappings(bankId: Option[String], callContext: Option[CallContext]): OBPReturnType[List[EndpointMappingT]] = Future{
import scala.concurrent.duration._
validateBankId(bankId, callContext)
@ -3064,7 +3064,7 @@ object NewStyle extends MdcLoggable{
var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
CacheKeyFromArguments.buildCacheKey {
Caching.memoizeSyncWithProvider(Some(cacheKey.toString()))(endpointMappingTTL second) {
Future{(EndpointMappingProvider.endpointMappingProvider.vend.getAllEndpointMappings(bankId), callContext)}
{(EndpointMappingProvider.endpointMappingProvider.vend.getAllEndpointMappings(bankId), callContext)}
}
}
}

View File

@ -360,7 +360,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
}
// TODO Cache this as long as fromDate and toDate are in the past (before now)
override def getTopApisFuture(queryParams: List[OBPQueryParam]): Future[Box[List[TopApi]]] = {
override def getTopApisFuture(queryParams: List[OBPQueryParam]): Future[Box[List[TopApi]]] = Future{
/**
* Please note that "var cacheKey = (randomUUID().toString, randomUUID().toString, randomUU
* is just a temporary value field with UUID values in order to prevent any ambiguity.
@ -369,7 +369,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
*/
var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
CacheKeyFromArguments.buildCacheKey {Caching.memoizeSyncWithProvider(Some(cacheKey.toString()))(cachedTopApis seconds){
Future{
{
val fromDate = queryParams.collect { case OBPFromDate(value) => value }.headOption
val toDate = queryParams.collect { case OBPToDate(value) => value }.headOption
val consumerId = queryParams.collect { case OBPConsumerId(value) => value }.headOption.flatMap(consumerIdToPrimaryKey)
@ -440,7 +440,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
}}
// TODO Cache this as long as fromDate and toDate are in the past (before now)
override def getTopConsumersFuture(queryParams: List[OBPQueryParam]): Future[Box[List[TopConsumer]]] = {
override def getTopConsumersFuture(queryParams: List[OBPQueryParam]): Future[Box[List[TopConsumer]]] = Future {
/**
* Please note that "var cacheKey = (randomUUID().toString, randomUUID().toString, randomUU
* is just a temporary value field with UUID values in order to prevent any ambiguity.
@ -449,7 +449,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
*/
var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
CacheKeyFromArguments.buildCacheKey {Caching.memoizeSyncWithProvider(Some(cacheKey.toString()))(cachedTopConsumers seconds){
Future {
val fromDate = queryParams.collect { case OBPFromDate(value) => value }.headOption
val toDate = queryParams.collect { case OBPToDate(value) => value }.headOption
val consumerId = queryParams.collect { case OBPConsumerId(value) => value }.headOption.flatMap(consumerIdToPrimaryKey)
@ -519,7 +519,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
}
tryo(result)
}
}}}
}}
}