|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.http.impl.client.cache.memcached.MemcachedHttpCacheStorage
public class MemcachedHttpCacheStorage
This class is a storage backend that uses an external memcached for storing cached origin responses. This storage option provides a couple of interesting advantages over the default in-memory storage backend:
Please refer to the memcached documentation and in particular to the documentation for the spymemcached documentation for details about how to set up and configure memcached and the Java client used here, respectively.
Constructor Summary | |
---|---|
MemcachedHttpCacheStorage(InetSocketAddress address)
Create a storage backend talking to a memcached instance listening on the specified host and port. |
|
MemcachedHttpCacheStorage(net.spy.memcached.MemcachedClientIF cache)
Create a storage backend using the pre-configured given memcached client. |
|
MemcachedHttpCacheStorage(net.spy.memcached.MemcachedClientIF client,
CacheConfig config,
HttpCacheEntrySerializer serializer)
Create a storage backend using the given memcached client and applying the given cache configuration and cache entry serialization mechanism. |
Method Summary | |
---|---|
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 |
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 MemcachedHttpCacheStorage(InetSocketAddress address) throws IOException
address
- where the memcached daemon is running
IOException
public MemcachedHttpCacheStorage(net.spy.memcached.MemcachedClientIF cache)
cache
- client to use for communicating with memcachedpublic MemcachedHttpCacheStorage(net.spy.memcached.MemcachedClientIF client, CacheConfig config, HttpCacheEntrySerializer serializer)
client
- how to talk to memcachedconfig
- apply HTTP cache-related optionsserializer
- how to serialize the cache entries before writing
them out to memcached. The provided DefaultHttpCacheEntrySerializer
is a fine serialization mechanism
to use here.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 HttpCacheUpdateException, 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.
HttpCacheUpdateException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |