@Contract(threading=SAFE) public class BasicHttpCacheStorage extends Object implements HttpCacheStorage
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.| Constructor and Description |
|---|
BasicHttpCacheStorage(CacheConfig config) |
| Modifier and Type | Method and Description |
|---|---|
HttpCacheEntry |
getEntry(String url)
Gets an entry from the cache, if it exists
|
void |
putEntry(String url,
HttpCacheEntry entry)
Places a HttpCacheEntry in the cache
|
void |
removeEntry(String url)
Removes a HttpCacheEntry from the cache
|
void |
updateEntry(String url,
HttpCacheUpdateCallback callback)
Atomically applies the given callback to update an existing cache
entry under a given key.
|
public BasicHttpCacheStorage(CacheConfig config)
public void putEntry(String url, HttpCacheEntry entry) throws IOException
putEntry in interface HttpCacheStorageurl - Url to use as the cache keyentry - HttpCacheEntry to place in the cacheIOExceptionpublic HttpCacheEntry getEntry(String url) throws IOException
getEntry in interface HttpCacheStorageurl - Url that is the cache keyIOExceptionpublic void removeEntry(String url) throws IOException
removeEntry in interface HttpCacheStorageurl - Url that is the cache keyIOExceptionpublic void updateEntry(String url, HttpCacheUpdateCallback callback) throws IOException
HttpCacheStorageupdateEntry in interface HttpCacheStorageurl - indicates which entry to modifycallback - performs the update; see
HttpCacheUpdateCallback for details, but roughly the
callback expects to be handed the current entry and will return
the new value for the entry.IOExceptionCopyright © 1999–2022 The Apache Software Foundation. All rights reserved.