Class BasicHttpCacheStorage
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.BasicHttpCacheStorage
-
- All Implemented Interfaces:
HttpCacheStorage
@Contract(threading=SAFE) public class BasicHttpCacheStorage extends java.lang.Object implements HttpCacheStorage
BasicHttpCacheStorageimplementation backed by an instance ofLinkedHashMap. In other words, cache entries and the cached response bodies are held in-memory. This cache does NOT deallocate resources associated with the cache entries; it is intended for use withHeapResourceand similar. This is the default cache storage backend used byCachingHttpClients.- Since:
- 4.1
-
-
Constructor Summary
Constructors Constructor Description BasicHttpCacheStorage(CacheConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,HttpCacheEntry>getEntries(java.util.Collection<java.lang.String> keys)Retrieves multiple cache entries stored under the given keys.HttpCacheEntrygetEntry(java.lang.String url)Gets an entry from the cache, if it existsvoidputEntry(java.lang.String url, HttpCacheEntry entry)Places a HttpCacheEntry in the cachevoidremoveEntry(java.lang.String url)Removes a HttpCacheEntry from the cachevoidupdateEntry(java.lang.String url, HttpCacheCASOperation casOperation)Atomically applies the given callback to processChallenge an existing cache entry under a given key.
-
-
-
Field Detail
-
entries
private final CacheMap entries
-
-
Constructor Detail
-
BasicHttpCacheStorage
public BasicHttpCacheStorage(CacheConfig config)
-
-
Method Detail
-
putEntry
public void putEntry(java.lang.String url, HttpCacheEntry entry) throws ResourceIOExceptionPlaces a HttpCacheEntry in the cache- Specified by:
putEntryin interfaceHttpCacheStorage- Parameters:
url- Url to use as the cache keyentry- HttpCacheEntry to place in the cache- Throws:
ResourceIOException
-
getEntry
public HttpCacheEntry getEntry(java.lang.String url) throws ResourceIOException
Gets an entry from the cache, if it exists- Specified by:
getEntryin interfaceHttpCacheStorage- Parameters:
url- Url that is the cache key- Returns:
- HttpCacheEntry if one exists, or null for cache miss
- Throws:
ResourceIOException
-
removeEntry
public void removeEntry(java.lang.String url) throws ResourceIOExceptionRemoves a HttpCacheEntry from the cache- Specified by:
removeEntryin interfaceHttpCacheStorage- Parameters:
url- Url that is the cache key- Throws:
ResourceIOException
-
updateEntry
public void updateEntry(java.lang.String url, HttpCacheCASOperation casOperation) throws ResourceIOExceptionDescription copied from interface:HttpCacheStorageAtomically applies the given callback to processChallenge an existing cache entry under a given key.- Specified by:
updateEntryin interfaceHttpCacheStorage- Parameters:
url- indicates which entry to modifycasOperation- the CAS operation to perform.- Throws:
ResourceIOException
-
getEntries
public java.util.Map<java.lang.String,HttpCacheEntry> getEntries(java.util.Collection<java.lang.String> keys) throws ResourceIOException
Description copied from interface:HttpCacheStorageRetrieves multiple cache entries stored under the given keys. Some implementations may use a single bulk operation to do the retrieval.- Specified by:
getEntriesin interfaceHttpCacheStorage- Parameters:
keys- cache keys- Returns:
- an map of
HttpCacheEntrys. - Throws:
ResourceIOException
-
-