public class EhcacheHttpCacheStorage<T> extends AbstractSerializingCacheStorage<T,T>
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
CacheConfig.getMaxCacheEntries()
maximum cache entries}
specified by a provided CacheConfig
.
Please refer to the Ehcache documentation for details on how to configure the Ehcache itself.
Constructor and Description |
---|
EhcacheHttpCacheStorage(org.ehcache.Cache<String,T> cache,
CacheConfig config,
HttpCacheEntrySerializer<T> serializer)
Constructs a storage backend using the provided Ehcache
with the given configuration options, but using an alternative
cache entry serialization strategy.
|
Modifier and Type | Method and Description |
---|---|
protected Map<String,T> |
bulkRestore(Collection<String> storageKeys) |
static EhcacheHttpCacheStorage<HttpCacheStorageEntry> |
createObjectCache(org.ehcache.Cache<String,HttpCacheStorageEntry> cache,
CacheConfig config)
Creates cache that stores
HttpCacheStorageEntry s without direct serialization. |
static EhcacheHttpCacheStorage<byte[]> |
createSerializedCache(org.ehcache.Cache<String,byte[]> cache,
CacheConfig config)
Creates cache that stores serialized
HttpCacheStorageEntry s. |
protected void |
delete(String storageKey) |
protected String |
digestToStorageKey(String key) |
protected T |
getForUpdateCAS(String storageKey) |
protected T |
getStorageObject(T element) |
protected T |
restore(String storageKey) |
protected void |
store(String storageKey,
T storageObject) |
protected boolean |
updateCAS(String storageKey,
T oldStorageObject,
T storageObject) |
getEntries, getEntry, putEntry, removeEntry, updateEntry
public EhcacheHttpCacheStorage(org.ehcache.Cache<String,T> cache, CacheConfig config, HttpCacheEntrySerializer<T> 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 mechanismpublic static EhcacheHttpCacheStorage<HttpCacheStorageEntry> createObjectCache(org.ehcache.Cache<String,HttpCacheStorageEntry> cache, CacheConfig config)
HttpCacheStorageEntry
s without direct serialization.public static EhcacheHttpCacheStorage<byte[]> createSerializedCache(org.ehcache.Cache<String,byte[]> cache, CacheConfig config)
HttpCacheStorageEntry
s.protected String digestToStorageKey(String key)
digestToStorageKey
in class AbstractSerializingCacheStorage<T,T>
protected void store(String storageKey, T storageObject) throws ResourceIOException
store
in class AbstractSerializingCacheStorage<T,T>
ResourceIOException
protected T restore(String storageKey) throws ResourceIOException
restore
in class AbstractSerializingCacheStorage<T,T>
ResourceIOException
protected T getForUpdateCAS(String storageKey) throws ResourceIOException
getForUpdateCAS
in class AbstractSerializingCacheStorage<T,T>
ResourceIOException
protected T getStorageObject(T element) throws ResourceIOException
getStorageObject
in class AbstractSerializingCacheStorage<T,T>
ResourceIOException
protected boolean updateCAS(String storageKey, T oldStorageObject, T storageObject) throws ResourceIOException
updateCAS
in class AbstractSerializingCacheStorage<T,T>
ResourceIOException
protected void delete(String storageKey) throws ResourceIOException
delete
in class AbstractSerializingCacheStorage<T,T>
ResourceIOException
protected Map<String,T> bulkRestore(Collection<String> storageKeys) throws ResourceIOException
bulkRestore
in class AbstractSerializingCacheStorage<T,T>
ResourceIOException
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.