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
Modifier and TypeFieldDescriptionstatic final ApacheHttpClient5Cache
Constant implementation of with disabled the cache logic. -
Method Summary
Modifier and TypeMethodDescriptionstatic ApacheHttpClient5Cache
newDefaultCache
(Duration cacheDuration) Creates a newHttpClient5Cache
with the givencacheDuration
.io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient>
tryGetHttpClient
(ApacheHttpClient5Factory httpClientFactory) Gets the non-destination-specificHttpClient
from this cache.io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient>
tryGetHttpClient
(HttpDestinationProperties destination, ApacheHttpClient5Factory httpClientFactory) Gets theHttpClient
for the givenDestination
from 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 newHttpClient5Cache
with the givencacheDuration
.- Parameters:
cacheDuration
- The duration for whichHttpClient
instances will be cached.- Returns:
- A new
HttpClient5Cache
instance.
-
tryGetHttpClient
@Nonnull io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient> tryGetHttpClient(@Nonnull HttpDestinationProperties destination, @Nonnull ApacheHttpClient5Factory httpClientFactory) Gets theHttpClient
for the givenDestination
from this cache.If there is no
HttpClient
fordestination
it is created by using theHttpClient5Factory
.- Parameters:
destination
- TheDestination
to get theHttpClient
for.httpClientFactory
- TheHttpClient5Factory
used to create a newHttpClient
if no cached one can be found.- Returns:
- The cached
HttpClient
for 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-specificHttpClient
from this cache.If there is no generic
HttpClient
it is created by using theHttpClient5Factory
.- Parameters:
httpClientFactory
- TheHttpClient5Factory
used to create a newHttpClient
if no cached one can be found.- Returns:
- The cached
HttpClient
.
-