Interface ApacheHttpClient5Cache
public interface ApacheHttpClient5Cache
Provides caching functionality to the
HttpClient5Accessor.
A default implementation of this interface can be instantiated by using the ApacheHttpClient5CacheBuilder.
- Since:
- 4.20.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ApacheHttpClient5CacheConstant implementation of with disabled the cache logic. -
Method Summary
Modifier and TypeMethodDescriptionstatic ApacheHttpClient5CachenewDefaultCache(Duration cacheDuration) Creates a newHttpClient5Cachewith the givencacheDuration.io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient>tryGetHttpClient(ApacheHttpClient5Factory httpClientFactory) Gets the non-destination-specificHttpClientfrom this cache.io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient>tryGetHttpClient(HttpDestinationProperties destination, ApacheHttpClient5Factory httpClientFactory) Gets theHttpClientfor the givenDestinationfrom this cache.
-
Field Details
-
DISABLED
Constant implementation of with disabled the cache logic. Useful for testing and troubleshooting. Don't use in production.
-
-
Method Details
-
newDefaultCache
Creates a newHttpClient5Cachewith the givencacheDuration.- Parameters:
cacheDuration- The duration for whichHttpClientinstances will be cached.- Returns:
- A new
HttpClient5Cacheinstance.
-
tryGetHttpClient
@Nonnull io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient> tryGetHttpClient(@Nonnull HttpDestinationProperties destination, @Nonnull ApacheHttpClient5Factory httpClientFactory) Gets theHttpClientfor the givenDestinationfrom this cache.If there is no
HttpClientfordestinationit is created by using theHttpClient5Factory.- Parameters:
destination- TheDestinationto get theHttpClientfor.httpClientFactory- TheHttpClient5Factoryused to create a newHttpClientif no cached one can be found.- Returns:
- The cached
HttpClientfor the givenDestination. - Throws:
HttpClientInstantiationException- If there is an issue while retrieving theHttpClient.
-
tryGetHttpClient
@Nonnull io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient> tryGetHttpClient(@Nonnull ApacheHttpClient5Factory httpClientFactory) Gets the non-destination-specificHttpClientfrom this cache.If there is no generic
HttpClientit is created by using theHttpClient5Factory.- Parameters:
httpClientFactory- TheHttpClient5Factoryused to create a newHttpClientif no cached one can be found.- Returns:
- The cached
HttpClient.
-