CachingDirectives

Use these directives to “wrap” expensive operations with a caching layer that runs the wrapped operation only once and returns the the cached value for all future accesses for the same key (as long as the respective entry has not expired). See caching for an introduction to how the caching support works.

Dependency

To use Akka HTTP Caching, add the module to your project:

sbt
libraryDependencies += "com.typesafe.akka" %% "akka-http-caching" % "10.1.8"
Gradle
dependencies {
  compile group: 'com.typesafe.akka', name: 'akka-http-caching_2.12', version: '10.1.8'
}
Maven
<dependency>
  <groupId>com.typesafe.akka</groupId>
  <artifactId>akka-http-caching_2.12</artifactId>
  <version>10.1.8</version>
</dependency>

Imports

Directives are available by importing:

Scala
import akka.http.scaladsl.server.directives.CachingDirectives._
Java
import static akka.http.javadsl.server.directives.CachingDirectives.*;
Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.