Class AbstractSerializingCacheStorage<T,CAS>
java.lang.Object
org.apache.hc.client5.http.impl.cache.AbstractSerializingCacheStorage<T,CAS>
- All Implemented Interfaces:
HttpCacheStorage
- Direct Known Subclasses:
AbstractBinaryCacheStorage
public abstract class AbstractSerializingCacheStorage<T,CAS>
extends Object
implements HttpCacheStorage
Abstract cache backend for serialized objects capable of CAS (compare-and-swap) updates.
- Since:
- 5.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSerializingCacheStorage(int maxUpdateRetries, HttpCacheEntrySerializer<T> serializer) -
Method Summary
Modifier and TypeMethodDescriptionbulkRestore(Collection<String> storageKeys) protected abstract voidprotected abstract StringdigestToStorageKey(String key) final Map<String, HttpCacheEntry> getEntries(Collection<String> keys) Retrieves multiple cache entries stored under the given keys.final HttpCacheEntryRetrieves the cache entry stored under the given key or null if no entry exists under that key.protected abstract CASgetForUpdateCAS(String storageKey) protected abstract TgetStorageObject(CAS cas) final voidputEntry(String key, HttpCacheEntry entry) Store a given cache entry under the given key.final voidremoveEntry(String key) Deletes/invalidates/removes any cache entries currently stored under the given key.protected abstract Tprotected abstract voidprotected abstract booleanfinal voidupdateEntry(String key, HttpCacheCASOperation casOperation) Atomically applies the given callback to processChallenge an existing cache entry under a given key.
-
Field Details
-
maxUpdateRetries
private final int maxUpdateRetries -
serializer
-
-
Constructor Details
-
AbstractSerializingCacheStorage
public AbstractSerializingCacheStorage(int maxUpdateRetries, HttpCacheEntrySerializer<T> serializer)
-
-
Method Details
-
digestToStorageKey
-
store
- Throws:
ResourceIOException
-
restore
- Throws:
ResourceIOException
-
getForUpdateCAS
- Throws:
ResourceIOException
-
getStorageObject
- Throws:
ResourceIOException
-
updateCAS
protected abstract boolean updateCAS(String storageKey, CAS cas, T storageObject) throws ResourceIOException - Throws:
ResourceIOException
-
delete
- Throws:
ResourceIOException
-
bulkRestore
protected abstract Map<String,T> bulkRestore(Collection<String> storageKeys) throws ResourceIOException - Throws:
ResourceIOException
-
putEntry
Description copied from interface:HttpCacheStorageStore a given cache entry under the given key.- Specified by:
putEntryin interfaceHttpCacheStorage- Parameters:
key- where in the cache to store the entryentry- cached response to store- Throws:
ResourceIOException
-
getEntry
Description copied from interface:HttpCacheStorageRetrieves the cache entry stored under the given key or null if no entry exists under that key.- Specified by:
getEntryin interfaceHttpCacheStorage- Parameters:
key- cache key- Returns:
- an
HttpCacheEntryornullif no entry exists - Throws:
ResourceIOException
-
removeEntry
Description copied from interface:HttpCacheStorageDeletes/invalidates/removes any cache entries currently stored under the given key.- Specified by:
removeEntryin interfaceHttpCacheStorage- Parameters:
key-- Throws:
ResourceIOException
-
updateEntry
public final void updateEntry(String key, HttpCacheCASOperation casOperation) throws HttpCacheUpdateException, ResourceIOException Description copied from interface:HttpCacheStorageAtomically applies the given callback to processChallenge an existing cache entry under a given key.- Specified by:
updateEntryin interfaceHttpCacheStorage- Parameters:
key- indicates which entry to modifycasOperation- the CAS operation to perform.- Throws:
HttpCacheUpdateExceptionResourceIOException
-
getEntries
public final Map<String, HttpCacheEntry> getEntries(Collection<String> keys) throws ResourceIOException Description copied from interface:HttpCacheStorageRetrieves multiple cache entries stored under the given keys. Some implementations may use a single bulk operation to do the retrieval.- Specified by:
getEntriesin interfaceHttpCacheStorage- Parameters:
keys- cache keys- Returns:
- an map of
HttpCacheEntrys. - Throws:
ResourceIOException
-