Class DefaultHttpClientCache
java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache
com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpClientCache
- All Implemented Interfaces:
HttpClientCache
Implementation of the
HttpClientCache, caching the HttpClients for the amount of time given in the
constructor.-
Field Summary
Fields inherited from interface com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientCache
DISABLED -
Constructor Summary
ConstructorsConstructorDescriptionDefaultHttpClientCache(long duration, TimeUnit unit) Caches theHttpClientfor the given duration after it has been accessed last. -
Method Summary
Modifier and TypeMethodDescriptionprotected io.vavr.control.Try<com.github.benmanes.caffeine.cache.Cache<CacheKey,org.apache.http.client.HttpClient>> getCache()Getter for the cache to be used.protected io.vavr.control.Try<CacheKey>Method called in the#getClient(HttpClientFactory)method to create aCacheKeyfor no specificDestination.protected io.vavr.control.Try<CacheKey>getCacheKey(HttpDestinationProperties destination) Method called in the#getClient(Destination, HttpClientFactory)method to create aCacheKeyfor the givenDestination.Methods inherited from class com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache
tryGetHttpClient, tryGetHttpClient
-
Constructor Details
-
DefaultHttpClientCache
Caches theHttpClientfor the given duration after it has been accessed last.- Parameters:
duration- The number of time units to store theHttpClients.unit- TheTimeUnitthe duration is given in.
-
-
Method Details
-
getCache
@Nonnull protected io.vavr.control.Try<com.github.benmanes.caffeine.cache.Cache<CacheKey,org.apache.http.client.HttpClient>> getCache()Description copied from class:AbstractHttpClientCacheGetter for the cache to be used.If the optional is empty a new
HttpClientwill be created and not cached.- Specified by:
getCachein classAbstractHttpClientCache- Returns:
- A
Tryof the cache to be used by theAbstractHttpClientCache.tryGetHttpClient(HttpDestinationProperties, HttpClientFactory)method.
-
getCacheKey
@Nonnull protected io.vavr.control.Try<CacheKey> getCacheKey(@Nonnull HttpDestinationProperties destination) Description copied from class:AbstractHttpClientCacheMethod called in the#getClient(Destination, HttpClientFactory)method to create aCacheKeyfor the givenDestination.- Specified by:
getCacheKeyin classAbstractHttpClientCache- Parameters:
destination- The destination to create aCacheKeyfor.- Returns:
- A
Tryof theCacheKeyfordestination.
-
getCacheKey
Description copied from class:AbstractHttpClientCacheMethod called in the#getClient(HttpClientFactory)method to create aCacheKeyfor no specificDestination.- Specified by:
getCacheKeyin classAbstractHttpClientCache- Returns:
- A
Tryof theCacheKeyfor a genericHttpClient.
-