|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.http.impl.client.cache.ManagedHttpCacheStorage
@ThreadSafe public class ManagedHttpCacheStorage
HttpCacheStorage
implementation capable of deallocating resources associated with
the cache entries. This cache keeps track of cache entries using PhantomReference
and maintains a collection of all resources that are no longer in use. The cache, however,
does not automatically deallocates associated resources by invoking Resource.dispose()
method. The consumer MUST periodically call cleanResources()
method to trigger
resource deallocation. The cache can be permanently shut down using shutdown()
method. All resources associated with the entries used by the cache will be deallocated.
This HttpCacheStorage
implementation is intended for use with FileResource
and similar.
Constructor Summary | |
---|---|
ManagedHttpCacheStorage(CacheConfig config)
|
Method Summary | |
---|---|
void |
cleanResources()
|
void |
close()
|
HttpCacheEntry |
getEntry(String url)
Retrieves the cache entry stored under the given key or null if no entry exists under that key. |
void |
putEntry(String url,
HttpCacheEntry entry)
Store a given cache entry under the given key. |
void |
removeEntry(String url)
Deletes/invalidates/removes any cache entries currently stored under the given key. |
void |
shutdown()
|
void |
updateEntry(String url,
HttpCacheUpdateCallback callback)
Atomically applies the given callback to update an existing cache entry under a given key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ManagedHttpCacheStorage(CacheConfig config)
Method Detail |
---|
public void putEntry(String url, HttpCacheEntry entry) throws IOException
HttpCacheStorage
putEntry
in interface HttpCacheStorage
url
- where in the cache to store the entryentry
- cached response to store
IOException
public HttpCacheEntry getEntry(String url) throws IOException
HttpCacheStorage
getEntry
in interface HttpCacheStorage
url
- cache key
HttpCacheEntry
or null
if no
entry exists
IOException
public void removeEntry(String url) throws IOException
HttpCacheStorage
removeEntry
in interface HttpCacheStorage
IOException
public void updateEntry(String url, HttpCacheUpdateCallback callback) throws 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.
IOException
public void cleanResources()
public void shutdown()
public void close()
close
in interface Closeable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |