public final class Cache
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Cache.Pair<RequestT,ResponseT>
A simple POJO that holds both cache read and write
PTransforms. |
| Constructor and Description |
|---|
Cache() |
| Modifier and Type | Method and Description |
|---|---|
static <RequestT,ResponseT> |
usingRedis(java.net.URI uri,
Coder<RequestT> requestTCoder,
Coder<ResponseT> responseTCoder,
Duration expiry)
|
public static <RequestT,ResponseT> Cache.Pair<RequestT,ResponseT> usingRedis(java.net.URI uri, Coder<RequestT> requestTCoder, Coder<ResponseT> responseTCoder, Duration expiry) throws Coder.NonDeterministicException
Cache.Pair using a Redis cache to read and write
RequestT and ResponseT pairs. The purpose of the cache is to offload RequestTs from the API and instead return the ResponseT if the association is known.
Since the RequestTs and ResponseTs need encoding and decoding, checks are made
whether the requestTCoder and responseTCoders are Coder.verifyDeterministic().
This feature is only appropriate for API reads such as HTTP list, get, etc.
Below describes the parameters in more detail and their usage.
URI uri - the URI of the Redis instance.
Coder<RequestT> requestTCoder - the RequestT Coder to encode and
decode RequestTs during cache read and writes.
Duration expiry - the duration to hold RequestT and ResponseT
pairs in the cache.
Coder.NonDeterministicException