Class CachedSupplier<T>
- java.lang.Object
-
- software.amazon.awssdk.utils.cache.CachedSupplier<T>
-
- All Implemented Interfaces:
AutoCloseable,Supplier<T>,SdkAutoCloseable
@SdkProtectedApi public class CachedSupplier<T> extends Object implements Supplier<T>, SdkAutoCloseable
A wrapper for aSupplierthat 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, theOneCallerBlocksstrategy will have a single caller block to update the value, and theNonBlockingstrategy maintains a thread pool for updating the value asynchronously in the background. This should be created usingbuilder(Supplier).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCachedSupplier.Builder<T>A Builder forCachedSupplier, created bybuilder(Supplier).static interfaceCachedSupplier.PrefetchStrategyThe way in which the cache should be pre-fetched when the data'sRefreshResult.prefetchTime()arrives.static classCachedSupplier.StaleValueBehaviorHow the cached supplier should behave when a stale value is retrieved from the underlying supplier or the underlying supplier fails while the cached value is stale.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> CachedSupplier.Builder<T>builder(Supplier<RefreshResult<T>> valueSupplier)Retrieve a builder that can be used for creating aCachedSupplier.voidclose()Free any resources consumed by the prefetch strategy this supplier is using.Tget()
-
-
-
Method Detail
-
builder
public static <T> CachedSupplier.Builder<T> builder(Supplier<RefreshResult<T>> valueSupplier)
Retrieve a builder that can be used for creating aCachedSupplier.- Parameters:
valueSupplier- The value supplier that should have its value cached.
-
close
public void close()
Free any resources consumed by the prefetch strategy this supplier is using.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSdkAutoCloseable
-
-