在我的应用程序中,我想缓存http请求,所以我按照以下文档:https://www.playframework.com/documentation/2.6.x/ScalaCache#Caching-HTTP-responses
通过这种方式来缓存请求我的应用程序运行良好,但是当我想测试控制器时我遇到了问题。
我无法测试那些需要将请求引入操作的控制器方法。像这样的方法:
def getObject(id: Int) = {
cached("/objects/" + id) {
Action.async { implicit request => {
service.getById(id).map(item => item match {
case None => NoContent
case _ => Ok(Json.toJson(item))
}
}
}
}
当我尝试测试这种类型的方法时,当方法调用模拟的service
提前致谢