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
Note
The Akka dependencies are available from Akka’s secure library repository. To access them you need to use a secure, tokenized URL as specified at https://account.akka.io/token.
To use Akka HTTP Caching, add the module to your project:
- sbt
val AkkaHttpVersion = "10.7.2" libraryDependencies += "com.typesafe.akka" %% "akka-http-caching" % AkkaHttpVersion
- Gradle
def versions = [ ScalaBinary: "2.13" ] dependencies { implementation platform("com.typesafe.akka:akka-http-bom_${versions.ScalaBinary}:10.7.2") implementation "com.typesafe.akka:akka-http-caching_${versions.ScalaBinary}" }
- Maven
<properties> <scala.binary.version>2.13</scala.binary.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>com.typesafe.akka</groupId> <artifactId>akka-http-bom_${scala.binary.version}</artifactId> <version>10.7.2</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.typesafe.akka</groupId> <artifactId>akka-http-caching_${scala.binary.version}</artifactId> </dependency> </dependencies>
Imports
Directives are available by importing: