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
The Akka dependencies are available from Akka’s library repository. To access them there, you need to configure the URL for this repository.
sbt resolvers += "Akka library repository" . at ( "https://repo.akka.io/maven" )
Gradle repositories {
mavenCentral ()
maven {
url "https://repo.akka.io/maven"
}
}
Maven <project>
...
<repositories>
<repository>
<id> akka-repository </id>
<name> Akka library repository </name>
<url> https://repo.akka.io/maven </url>
</repository>
</repositories>
</project>
To use Akka HTTP Caching, add the module to your project:
sbt val AkkaHttpVersion = "10.7.0"
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.0" )
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.0 </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:
Scala
copy source import akka . http . scaladsl . server . directives . CachingDirectives . _
Java
copy source import static akka . http . javadsl . server . directives . CachingDirectives .*;