play.api.libs.ws.ahc.cache

Members list

Type members

Classlikes

class AhcHttpCache(underlying: Cache, heuristicsEnabled: Boolean)(implicit val executionContext: ExecutionContext) extends CacheDefaults

Central HTTP cache. This keeps a cache of HTTP responses according to https://tools.ietf.org/html/rfc7234#section-2

Central HTTP cache. This keeps a cache of HTTP responses according to https://tools.ietf.org/html/rfc7234#section-2

The primary cache key consists of the request method and target URI. However, since HTTP caches in common use today are typically limited to caching responses to GET, many caches simply decline other methods and use only the URI as the primary cache key.

Attributes

Supertypes
trait AhcUtilities
trait CacheDefaults
trait Cache
class Object
trait Matchable
class Any
Show all
class AsyncCacheableConnection[T](asyncHandler: AsyncHandler[T], request: Request, response: CacheableResponse, future: ListenableFuture[T]) extends Callable[T]

Calls the relevant methods on the async handler, providing it with the cached response.

Calls the relevant methods on the async handler, providing it with the cached response.

Attributes

Companion
object
Supertypes
trait AhcUtilities
trait Callable[T]
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class AsyncCachingHandler[T](request: Request, handler: AsyncCompletionHandler[T], cache: AhcHttpCache, maybeAction: Option[ResponseServeAction], ahcConfig: AsyncHttpClientConfig) extends AsyncHandler[T], TimeoutResponse

An async handler that accumulates response data to place in cache with the given key.

An async handler that accumulates response data to place in cache with the given key.

Attributes

Companion
object
Supertypes
trait AhcUtilities
trait AsyncHandler[T]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class BackgroundAsyncHandler[T](request: Request, cache: AhcHttpCache, ahcConfig: AsyncHttpClientConfig) extends AsyncHandler[T]

An async handler that accumulates a response and stores it to cache in the background.

An async handler that accumulates a response and stores it to cache in the background.

Attributes

Companion
object
Supertypes
trait AhcUtilities
trait AsyncHandler[T]
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
trait Cache

A very simple cache trait.

A very simple cache trait.

Implementations can write adapters that map through to this trait, i.e.

import java.util.concurrent.TimeUnit
import scala.concurrent.Future

import com.github.benmanes.caffeine.cache.{ Caffeine, Ticker }

import play.api.libs.ws.ahc.cache.{
 Cache, EffectiveURIKey, ResponseEntry
}

class CaffeineHttpCache extends Cache {
 val underlying = Caffeine.newBuilder()
   .ticker(Ticker.systemTicker())
   .expireAfterWrite(365, TimeUnit.DAYS)
   .build[EffectiveURIKey, ResponseEntry]()

 def remove(key: EffectiveURIKey) =
   Future.successful(Option(underlying.invalidate(key)))

 def put(key: EffectiveURIKey, entry: ResponseEntry) =
   Future.successful(underlying.put(key, entry))

 def get(key: EffectiveURIKey) =
   Future.successful(Option(underlying getIfPresent key ))

 def close(): Unit = underlying.cleanUp()
}

Attributes

Supertypes
class Object
trait Matchable
class Any
class CacheFuture[T](handler: AsyncHandler[T]) extends ListenableFuture[T]

A wrapper to return a ListenableFuture.

A wrapper to return a ListenableFuture.

Attributes

Supertypes
trait ListenableFuture[T]
trait Future[T]
class Object
trait Matchable
class Any
class CacheableHttpResponseBodyPart(chunk: Array[Byte], last: Boolean) extends HttpResponseBodyPart

Attributes

Supertypes
class HttpResponseBodyPart
class Object
trait Matchable
class Any
class CacheableHttpResponseStatus(uri: Uri, statusCode: Int, statusText: String, protocolText: String) extends HttpResponseStatus

Attributes

Supertypes
class HttpResponseStatus
class Object
trait Matchable
class Any
case class CacheableResponse(status: CacheableHttpResponseStatus, headers: HttpHeaders, bodyParts: List[CacheableHttpResponseBodyPart], ahcConfig: AsyncHttpClientConfig) extends Response

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Response
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
class CacheableResponseBuilder(ahcConfig: AsyncHttpClientConfig)

Attributes

Supertypes
class Object
trait Matchable
class Any
class CachingAsyncHttpClient(underlying: AsyncHttpClient, ahcHttpCache: AhcHttpCache) extends AsyncHttpClient, TimeoutResponse

A provider that pulls a response from the cache.

A provider that pulls a response from the cache.

Attributes

Supertypes
trait AhcUtilities
trait AsyncHttpClient
trait Closeable
trait AutoCloseable
class Object
trait Matchable
class Any
Show all
case class EffectiveURIKey(method: String, uri: URI)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class ResponseEntry(response: CacheableResponse, requestMethod: String, nominatedHeaders: Map[HeaderName, Seq[String]], expiresAt: Option[ZonedDateTime])

A cache entry with an optional expiry time

A cache entry with an optional expiry time

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes