Class MemcachedHttpCacheStorage

java.lang.Object
org.apache.hc.client5.http.impl.cache.AbstractSerializingCacheStorage<byte[],CAS>
org.apache.hc.client5.http.impl.cache.AbstractBinaryCacheStorage<net.spy.memcached.CASValue<Object>>
org.apache.hc.client5.http.impl.cache.memcached.MemcachedHttpCacheStorage
All Implemented Interfaces:
HttpCacheStorage

public class MemcachedHttpCacheStorage extends AbstractBinaryCacheStorage<net.spy.memcached.CASValue<Object>>

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:

  1. in-memory cached objects can survive an application restart since they are held in a separate process
  2. it becomes possible for several cooperating applications to share a large memcached farm together

Note that in a shared memcached pool setting you may wish to make use of the Ketama consistent hashing algorithm to reduce the number of cache misses that might result if one of the memcached cluster members fails (see the KetamaConnectionFactory).

Because memcached places limits on the size of its keys, we need to introduce a key hashing scheme to map the annotated URLs the higher-level caching HTTP client wants to use as keys onto ones that are suitable for use with memcached. Please see KeyHashingScheme if you would like to use something other than the provided SHA256KeyHashingScheme.

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.

Since:
4.1