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 HttpClient
s 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
ConstructorDescriptionDefaultHttpClientCache
(long duration, TimeUnit unit) Caches theHttpClient
for 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 aCacheKey
for no specificDestination
.protected io.vavr.control.Try<CacheKey>
getCacheKey
(HttpDestinationProperties destination) Method called in the#getClient(Destination, HttpClientFactory)
method to create aCacheKey
for the givenDestination
.Methods inherited from class com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache
tryGetHttpClient, tryGetHttpClient
-
Constructor Details
-
DefaultHttpClientCache
Caches theHttpClient
for the given duration after it has been accessed last.- Parameters:
duration
- The number of time units to store theHttpClient
s.unit
- TheTimeUnit
the 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:AbstractHttpClientCache
Getter for the cache to be used.If the optional is empty a new
HttpClient
will be created and not cached.- Specified by:
getCache
in classAbstractHttpClientCache
- Returns:
- A
Try
of 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:AbstractHttpClientCache
Method called in the#getClient(Destination, HttpClientFactory)
method to create aCacheKey
for the givenDestination
.- Specified by:
getCacheKey
in classAbstractHttpClientCache
- Parameters:
destination
- The destination to create aCacheKey
for.- Returns:
- A
Try
of theCacheKey
fordestination.
-
getCacheKey
Description copied from class:AbstractHttpClientCache
Method called in the#getClient(HttpClientFactory)
method to create aCacheKey
for no specificDestination
.- Specified by:
getCacheKey
in classAbstractHttpClientCache
- Returns:
- A
Try
of theCacheKey
for a genericHttpClient
.
-