@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 |
---|---|
Map<String,HttpCacheEntry> |
getEntries(Collection<String> keys)
Retrieves multiple cache entries stored under the given keys.
|
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,
HttpCacheCASOperation casOperation)
Atomically applies the given callback to processChallenge an existing cache
entry under a given key.
|
public BasicHttpCacheStorage(CacheConfig config)
public void putEntry(String url, HttpCacheEntry entry) throws ResourceIOException
putEntry
in interface HttpCacheStorage
url
- Url to use as the cache keyentry
- HttpCacheEntry to place in the cacheResourceIOException
public HttpCacheEntry getEntry(String url) throws ResourceIOException
getEntry
in interface HttpCacheStorage
url
- Url that is the cache keyResourceIOException
public void removeEntry(String url) throws ResourceIOException
removeEntry
in interface HttpCacheStorage
url
- Url that is the cache keyResourceIOException
public void updateEntry(String url, HttpCacheCASOperation casOperation) throws ResourceIOException
HttpCacheStorage
updateEntry
in interface HttpCacheStorage
url
- indicates which entry to modifycasOperation
- the CAS operation to perform.ResourceIOException
public Map<String,HttpCacheEntry> getEntries(Collection<String> keys) throws ResourceIOException
HttpCacheStorage
getEntries
in interface HttpCacheStorage
keys
- cache keysHttpCacheEntry
s.ResourceIOException
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.