Package kong.unirest.core
Class CacheManager.CacheMap
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Cache.Key,
,Object> SequencedMap<Cache.Key,
,Object> Cache
- Enclosing class:
CacheManager
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> Nested classes/interfaces inherited from interface kong.unirest.core.Cache
Cache.Builder, Cache.Key, Cache.KeyGenerator
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
clearOld()
<T> HttpResponse
<T> get
(Cache.Key key, Supplier<HttpResponse<T>> fetcher) Returns the cached HttpResponse for a key or uses the Supplier to fetch the responsegetAsync
(Cache.Key key, Supplier<CompletableFuture<HttpResponse<T>>> fetcher) Returns the cached HttpResponse for a key or uses the Supplier to fetch the responseprotected boolean
removeEldestEntry
(Map.Entry<Cache.Key, Object> eldest) Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, values
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from interface java.util.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
-
Field Details
-
maxSize
private final int maxSize -
ttl
private long ttl
-
-
Constructor Details
-
CacheMap
CacheMap(int maxSize, long ttl)
-
-
Method Details
-
get
Description copied from interface:Cache
Returns the cached HttpResponse for a key or uses the Supplier to fetch the response -
getAsync
public <T> CompletableFuture getAsync(Cache.Key key, Supplier<CompletableFuture<HttpResponse<T>>> fetcher) Description copied from interface:Cache
Returns the cached HttpResponse for a key or uses the Supplier to fetch the response -
clearOld
private void clearOld() -
removeEldestEntry
- Overrides:
removeEldestEntry
in classLinkedHashMap<Cache.Key,
Object>
-