@Contract(threading=SAFE) public class BasicHttpCacheStorage extends java.lang.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(java.lang.String url)
Gets an entry from the cache, if it exists
|
void |
putEntry(java.lang.String url,
HttpCacheEntry entry)
Places a HttpCacheEntry in the cache
|
void |
removeEntry(java.lang.String url)
Removes a HttpCacheEntry from the cache
|
void |
updateEntry(java.lang.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(java.lang.String url, HttpCacheEntry entry) throws java.io.IOException
putEntry
in interface HttpCacheStorage
url
- Url to use as the cache keyentry
- HttpCacheEntry to place in the cachejava.io.IOException
public HttpCacheEntry getEntry(java.lang.String url) throws java.io.IOException
getEntry
in interface HttpCacheStorage
url
- Url that is the cache keyjava.io.IOException
public void removeEntry(java.lang.String url) throws java.io.IOException
removeEntry
in interface HttpCacheStorage
url
- Url that is the cache keyjava.io.IOException
public void updateEntry(java.lang.String url, HttpCacheUpdateCallback callback) throws java.io.IOException
HttpCacheStorage
updateEntry
in interface HttpCacheStorage
url
- 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.java.io.IOException
Copyright © 2010 - 2019 Adobe. All Rights Reserved