Class BasicHttpCacheStorage
java.lang.Object
org.apache.http.impl.client.cache.BasicHttpCacheStorage
- All Implemented Interfaces:
HttpCacheStorage
@Contract(threading=SAFE)
public class BasicHttpCacheStorage
extends Object
implements HttpCacheStorage
Basic
HttpCacheStorage
implementation backed by an instance of
LinkedHashMap
. 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 with HeapResource
and similar. This is the default cache
storage backend used by CachingHttpClients
.- Since:
- 4.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets an entry from the cache, if it existsvoid
putEntry
(String url, HttpCacheEntry entry) Places a HttpCacheEntry in the cachevoid
removeEntry
(String url) Removes a HttpCacheEntry from the cachevoid
updateEntry
(String url, HttpCacheUpdateCallback callback) Atomically applies the given callback to update an existing cache entry under a given key.
-
Constructor Details
-
BasicHttpCacheStorage
-
-
Method Details
-
putEntry
Places a HttpCacheEntry in the cache- Specified by:
putEntry
in interfaceHttpCacheStorage
- Parameters:
url
- Url to use as the cache keyentry
- HttpCacheEntry to place in the cache- Throws:
IOException
-
getEntry
Gets an entry from the cache, if it exists- Specified by:
getEntry
in interfaceHttpCacheStorage
- Parameters:
url
- Url that is the cache key- Returns:
- HttpCacheEntry if one exists, or null for cache miss
- Throws:
IOException
-
removeEntry
Removes a HttpCacheEntry from the cache- Specified by:
removeEntry
in interfaceHttpCacheStorage
- Parameters:
url
- Url that is the cache key- Throws:
IOException
-
updateEntry
Description copied from interface:HttpCacheStorage
Atomically applies the given callback to update an existing cache entry under a given key.- Specified by:
updateEntry
in interfaceHttpCacheStorage
- Parameters:
url
- indicates which entry to modifycallback
- performs the update; seeHttpCacheUpdateCallback
for details, but roughly the callback expects to be handed the current entry and will return the new value for the entry.- Throws:
IOException
-