public class TimeScopedHttpClientCache extends HttpClientCache
HttpClientCache
, caching the HttpClient
s for the amount of time given in the
constructor.Constructor and Description |
---|
TimeScopedHttpClientCache(long duration,
TimeUnit unit)
Caches the
HttpClient for the given duration. |
Modifier and Type | Method and Description |
---|---|
protected Optional<com.google.common.cache.Cache<CacheKey,org.apache.http.client.HttpClient>> |
getCache()
Getter for the cache to be used.
|
protected com.google.common.cache.CacheBuilder<Object,Object> |
getCacheBuilder(long duration,
TimeUnit unit) |
protected CacheKey |
getCacheKey(Destination destination)
Method called in the
#getClient(Destination, HttpClientFactory) method to create a CacheKey for
the given Destination . |
getHttpClient
public TimeScopedHttpClientCache(long duration, @NonNull TimeUnit unit)
HttpClient
for the given duration.duration
- The number of time units to store the HttpClient
s.unit
- The TimeUnit
the duration is given in.protected com.google.common.cache.CacheBuilder<Object,Object> getCacheBuilder(long duration, @NonNull TimeUnit unit)
protected Optional<com.google.common.cache.Cache<CacheKey,org.apache.http.client.HttpClient>> getCache()
If the optional is empty a new HttpClient
will be created and not cached.
getCache
in class HttpClientCache
Optional
that may contain the cache to be used by the
HttpClientCache.getHttpClient(Destination, HttpClientFactory)
method.protected CacheKey getCacheKey(Destination destination) throws HttpClientInstantiationException
#getClient(Destination, HttpClientFactory)
method to create a CacheKey
for
the given Destination
.getCacheKey
in class HttpClientCache
destination
- The destination to create a CacheKey
for.CacheKey
for destination.
HttpClientInstantiationException
- If there is an issue while accessing the cache key.Copyright © 2018 SAP SE. All rights reserved.