我正在尝试将 UserAwareAction 与缓存结合起来。我能够获得 CacheBeforeSilhouette 但不能反过来?谁能给我一个关于如何做到这一点的提示?
@Singleton
class MessageController @Inject() (
implicit val env: Environment[DefaultEnv],
silhouette: Silhouette[DefaultEnv],
cache: CacheApi,
cached: play.api.cache.Cached)
extends Controller with I18nSupport {
...
def testOnlySilhouette = silhouette.UserAwareAction { request =>
Ok("hi")
}
def testOnlyCache = cached("homePage") {
Action {
Ok("Hello world")
}
}
def testCacheOfSilhouette = cached("homePage") {
silhouette.UserAwareAction { request =>
Ok("hi")
}
}
def testSilhouetteOfCache =
silhouette.UserAwareAction { request =>
cached("homePage") {
val res:Result = Ok("hi")
res //type mismatch; found : play.api.mvc.Result required: play.api.mvc.EssentialAction
}
}