Mastering Play Framework for Scala by 2015
Author:2015
Language: eng
Format: mobi, epub
Publisher: Packt Publishing
All of this is handled by the Cached case class and its companion object. The case class is defined as follows:
case class Cached(key: RequestHeader => String, caching: PartialFunction[ResponseHeader, Duration]) { … }
The companion object provides commonly required methods to generate cached instances, such as cache action based on its status, and so on.
The apply method in cached calls the build method, which is defined as follows:
def build(action: EssentialAction)(implicit app: Application) = EssentialAction { request => val resultKey = key(request) val etagKey = s"$resultKey-etag" // Has the client a version of the resource as fresh as the last one we served? val notModified = for { requestEtag <- request.headers.get(IF_NONE_MATCH) etag <- Cache.getAs[String](etagKey) if requestEtag == "*" || etag == requestEtag } yield Done[Array[Byte], Result](NotModified) notModified.orElse { // Otherwise try to serve the resource from the cache, if it has not yet expired Cache.getAs[Result](resultKey).map(Done[Array[Byte], Result](_)) }.getOrElse { // The resource was not in the cache, we have to run the underlying action val iterateeResult = action(request) // Add cache information to the response, so clients can cache its content iterateeResult.map(handleResult(_, etagKey, resultKey, app)) } }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(9938)
The Mikado Method by Ola Ellnestam Daniel Brolund(9805)
Dependency Injection in .NET by Mark Seemann(9364)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7803)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7582)
Svelte with Test-Driven Development by Daniel Irvine(7368)
Test-Driven Development with PHP 8 by Rainier Sarabia(7111)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(6966)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6550)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6440)
Web Development with Django by Ben Shaw Saurabh Badhwar(6431)
React Application Architecture for Production by Alan Alickovic(6154)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5827)
Kotlin in Action by Dmitry Jemerov(5087)
Audition by Ryu Murakami(4604)
Software Architecture for Web Developers by Mihaela Roxana Ghidersa(4560)
Accelerating Server-Side Development with Fastify by Manuel Spigolon Maksim Sinik & Matteo Collina(4414)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4332)
Solidity Programming Essentials by Ritesh Modi(4117)
