|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.http.impl.client.cache.ehcache.EhcacheHttpCacheStorage
public class EhcacheHttpCacheStorage
This class is a storage backend for cache entries that uses the popular Ehcache cache implementation. In particular, this backend allows for spillover to disk, where the cache can be effectively larger than memory, and cached responses are paged into and out of memory from disk as needed.
N.B. Since the Ehcache is configured ahead of time with a
maximum number of cache entries, this effectively ignores the
maximum cache entries
specified by a provided CacheConfig
.
Please refer to the Ehcache documentation for details on how to configure the Ehcache itself.
Constructor Summary | |
---|---|
EhcacheHttpCacheStorage(net.sf.ehcache.Ehcache cache)
Constructs a storage backend using the provided Ehcache with default configuration options. |
|
EhcacheHttpCacheStorage(net.sf.ehcache.Ehcache cache,
CacheConfig config)
Constructs a storage backend using the provided Ehcache with the given configuration options. |
|
EhcacheHttpCacheStorage(net.sf.ehcache.Ehcache cache,
CacheConfig config,
HttpCacheEntrySerializer serializer)
Constructs a storage backend using the provided Ehcache with the given configuration options, but using an alternative cache entry serialization strategy. |
Method Summary | |
---|---|
HttpCacheEntry |
getEntry(String key)
Retrieves the cache entry stored under the given key or null if no entry exists under that key. |
void |
putEntry(String key,
HttpCacheEntry entry)
Store a given cache entry under the given key. |
void |
removeEntry(String key)
Deletes/invalidates/removes any cache entries currently stored under the given key. |
void |
updateEntry(String key,
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 EhcacheHttpCacheStorage(net.sf.ehcache.Ehcache cache)
cache
- where to store cached origin responsespublic EhcacheHttpCacheStorage(net.sf.ehcache.Ehcache cache, CacheConfig config)
cache
- where to store cached origin responsesconfig
- cache storage configuration options - note that
the setting for max object size will be ignored and
should be configured in the Ehcache instead.public EhcacheHttpCacheStorage(net.sf.ehcache.Ehcache cache, CacheConfig config, HttpCacheEntrySerializer serializer)
cache
- where to store cached origin responsesconfig
- cache storage configuration options - note that
the setting for max object size will be ignored and
should be configured in the Ehcache instead.serializer
- alternative serialization mechanismMethod Detail |
---|
public void putEntry(String key, HttpCacheEntry entry) throws IOException
HttpCacheStorage
putEntry
in interface HttpCacheStorage
key
- where in the cache to store the entryentry
- cached response to store
IOException
public HttpCacheEntry getEntry(String key) throws IOException
HttpCacheStorage
getEntry
in interface HttpCacheStorage
key
- cache key
HttpCacheEntry
or null
if no
entry exists
IOException
public void removeEntry(String key)
HttpCacheStorage
removeEntry
in interface HttpCacheStorage
public void updateEntry(String key, HttpCacheUpdateCallback callback) throws IOException, HttpCacheUpdateException
HttpCacheStorage
updateEntry
in interface HttpCacheStorage
key
- 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
HttpCacheUpdateException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |