public final class CachedSupplier<T> extends Object implements Supplier<T>, SdkAutoCloseable
Supplier that applies certain caching rules to the retrieval of its value, including customizable
pre-fetching behaviors for updating values as they get close to expiring so that not all threads have to block to update the
value.
For example, the OneCallerBlocks strategy will have a single caller block to update the value, and the
NonBlocking strategy maintains a thread pool for updating the value asynchronously in the background.
This should be created using builder(Supplier).| Modifier and Type | Class and Description |
|---|---|
static class |
CachedSupplier.Builder<T>
A Builder for
CachedSupplier, created by builder(Supplier). |
static interface |
CachedSupplier.PrefetchStrategy
The way in which the cache should be pre-fetched when the data's
RefreshResult.prefetchTime() arrives. |
| Modifier and Type | Method and Description |
|---|---|
static <T> CachedSupplier.Builder<T> |
builder(Supplier<RefreshResult<T>> valueSupplier)
Retrieve a builder that can be used for creating a
CachedSupplier. |
void |
close()
Free any resources consumed by the prefetch strategy this supplier is using.
|
T |
get() |
public static <T> CachedSupplier.Builder<T> builder(Supplier<RefreshResult<T>> valueSupplier)
CachedSupplier.valueSupplier - The value supplier that should have its value cached.public void close()
close in interface AutoCloseableclose in interface SdkAutoCloseableCopyright © 2017 Amazon Web Services, Inc. All Rights Reserved.