Skip to content

Commit

Permalink
#1410 Use different cache keys for v0 and v1 for describe
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jun 26, 2020
1 parent 2c370f9 commit 706c8db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions thehive/app/org/thp/thehive/controllers/v0/DescribeCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class DescribeCtrl @Inject() (
.auth { _ =>
entityDescriptions
.collectFirst {
case desc if desc.label == modelName => Success(Results.Ok(cacheApi.getOrElseUpdate(s"describe.$modelName", cacheExpire)(desc.toJson)))
case desc if desc.label == modelName => Success(Results.Ok(cacheApi.getOrElseUpdate(s"describe.v0.$modelName", cacheExpire)(desc.toJson)))
}
.getOrElse(Failure(NotFoundError(s"Model $modelName not found")))
}
Expand All @@ -173,7 +173,7 @@ class DescribeCtrl @Inject() (
entrypoint("describe all models")
.auth { _ =>
val descriptors = entityDescriptions.map { desc =>
desc.label -> cacheApi.getOrElseUpdate(s"describe.${desc.label}", cacheExpire)(desc.toJson)
desc.label -> cacheApi.getOrElseUpdate(s"describe.v0.${desc.label}", cacheExpire)(desc.toJson)
}
Success(Results.Ok(JsObject(descriptors)))
}
Expand Down
4 changes: 2 additions & 2 deletions thehive/app/org/thp/thehive/controllers/v1/DescribeCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class DescribeCtrl @Inject() (
.auth { _ =>
entityDescriptions
.collectFirst {
case desc if desc.label == modelName => Success(Results.Ok(cacheApi.getOrElseUpdate(s"describe.$modelName", cacheExpire)(desc.toJson)))
case desc if desc.label == modelName => Success(Results.Ok(cacheApi.getOrElseUpdate(s"describe.v1.$modelName", cacheExpire)(desc.toJson)))
}
.getOrElse(Failure(NotFoundError(s"Model $modelName not found")))
}
Expand All @@ -170,7 +170,7 @@ class DescribeCtrl @Inject() (
entrypoint("describe all models")
.auth { _ =>
val descriptors = entityDescriptions.map { desc =>
desc.label -> cacheApi.getOrElseUpdate(s"describe.${desc.label}", cacheExpire)(desc.toJson)
desc.label -> cacheApi.getOrElseUpdate(s"describe.v1.${desc.label}", cacheExpire)(desc.toJson)
}
Success(Results.Ok(JsObject(descriptors)))
}
Expand Down

0 comments on commit 706c8db

Please sign in to comment.