Skip to content

Commit

Permalink
Make remote query cache timeout configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
defect committed Jan 20, 2016
1 parent 62a9bd8 commit 6ff36d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/collins/models/RemoteAssetFinder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
1 change: 1 addition & 0 deletions app/collins/util/config/MultiCollinsConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions conf/reference/multicollins_reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ multicollins {
instanceAssetType = DATA_CENTER
locationAttribute = LOCATION
thisInstance = NONE
queryCacheTimeout = 30
}

0 comments on commit 6ff36d8

Please sign in to comment.