From 10bfffd01ae53a09b0292aff66765b34c6a366e3 Mon Sep 17 00:00:00 2001 From: Felix Aronsson Date: Wed, 20 Jan 2016 03:54:55 +0100 Subject: [PATCH] Make remote query cache timeout configurable --- app/collins/models/RemoteAssetFinder.scala | 4 +++- app/collins/util/config/MultiCollinsConfig.scala | 1 + conf/reference/multicollins_reference.conf | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/collins/models/RemoteAssetFinder.scala b/app/collins/models/RemoteAssetFinder.scala index 60c5635ab..b98df3826 100644 --- a/app/collins/models/RemoteAssetFinder.scala +++ b/app/collins/models/RemoteAssetFinder.scala @@ -26,6 +26,7 @@ import collins.solr.SolrOrOp import collins.solr.StringValueFormat import collins.util.AttributeResolver.ResultTuple import collins.util.RemoteCollinsHost +import collins.util.config.MultiCollinsConfig /** * Just a combination of everything needed to do a search. Probably should @@ -279,7 +280,8 @@ object RemoteAssetFinder { val key = searchParams.paginationKey.getOrElse("") + clients.map { _.tag }.mkString("_") val stream = Cache.getAs[RemoteAssetStream](key).getOrElse(new RemoteAssetStream(clients, searchParams)) val results = stream.slice(pageParams.page * pageParams.size, (pageParams.page + 1) * (pageParams.size)) - Cache.set(key, stream, 30) + val timeout = MultiCollinsConfig.queryCacheTimeout + Cache.set(key, stream, timeout) (results, stream.aggregateTotal) } diff --git a/app/collins/util/config/MultiCollinsConfig.scala b/app/collins/util/config/MultiCollinsConfig.scala index 1da319cf5..c04163ac2 100644 --- a/app/collins/util/config/MultiCollinsConfig.scala +++ b/app/collins/util/config/MultiCollinsConfig.scala @@ -18,6 +18,7 @@ object MultiCollinsConfig extends Configurable { } def locationAttribute = getString("locationAttribute", "LOCATION") def thisInstance = getString("thisInstance") + def queryCacheTimeout = getInt("queryCacheTimeout", 30) override def validateConfig() { if (enabled) { diff --git a/conf/reference/multicollins_reference.conf b/conf/reference/multicollins_reference.conf index 40e50bb95..9fb756674 100644 --- a/conf/reference/multicollins_reference.conf +++ b/conf/reference/multicollins_reference.conf @@ -3,4 +3,5 @@ multicollins { instanceAssetType = DATA_CENTER locationAttribute = LOCATION thisInstance = NONE + queryTimeout = 30 }