Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Include solr query string in cache key" #400

Merged
merged 1 commit into from
Jan 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/collins/models/AssetFinder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ case class AssetFinder(
updatedAfter.map(t => "updatedAfter" -> Formatter.dateFormat(t)) ::
updatedBefore.map(t => "updatedBefore" -> Formatter.dateFormat(t)) ::
state.map(s => "state" -> s.name) ::
query.map(q => "query" -> q.traverseQueryString) ::
query.map { q => "query" -> "UHOH!!!!" } :: //FIXME: need toCQL traversal
Nil)
items.flatten
}
Expand Down
6 changes: 2 additions & 4 deletions app/collins/models/RemoteAssetFinder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ 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 @@ -277,11 +276,10 @@ object RemoteAssetFinder {
/**
*/
def apply(clients: Seq[RemoteAssetClient], pageParams: PageParams, searchParams: AssetSearchParameters): (Seq[AssetView], Long) = {
val key = searchParams.paginationKey.getOrElse("") + clients.map { _.tag }.mkString("_")
val key = searchParams.paginationKey + 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))
val timeout = MultiCollinsConfig.queryCacheTimeout
Cache.set(key, stream, timeout)
Cache.set(key, stream, 30)
(results, stream.aggregateTotal)
}

Expand Down
2 changes: 1 addition & 1 deletion app/collins/solr/CollinsQueryLanguage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ case class CQLQuery(select: SolrDocType, where: SolrExpression) {
* itself into a Solr Query
*/
sealed trait SolrQueryComponent {
def traverseQueryString(): String = traverseQueryString(true)
protected[solr] def traverseQueryString(): String = traverseQueryString(true)
protected[solr] def traverseQueryString(toplevel: Boolean): String
}

Expand Down
1 change: 0 additions & 1 deletion app/collins/util/config/MultiCollinsConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ 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: 0 additions & 1 deletion conf/reference/multicollins_reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ multicollins {
instanceAssetType = DATA_CENTER
locationAttribute = LOCATION
thisInstance = NONE
queryCacheTimeout = 30
}
7 changes: 0 additions & 7 deletions test/collins/models/AssetSearchParametersSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package collins.models
import org.specs2._
import specification._

import collins.solr.SolrKeyVal
import collins.solr.SolrStringValue

class AssetSearchParametersSpec extends mutable.Specification {

val EMPTY_RESULT_TUPLE = (Nil, Nil, Nil)
Expand Down Expand Up @@ -96,10 +93,6 @@ class AssetSearchParametersSpec extends mutable.Specification {
).toSeq.findOne("attribute") must_== Some("ip_address;1.3.5.7")
}

"include CQL query" in {
AssetSearchParameters(EMPTY_RESULT_TUPLE, AssetFinder.empty.copy(query = Some(SolrKeyVal("foo", SolrStringValue("bar")))), None).toSeq.findOne("query") must_== Some("foo:\"bar\"")
}

}

"properly url-encode values" in {
Expand Down