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 void
protected abstract String
digestToStorageKey
(String key) final Map
<String, HttpCacheEntry> getEntries
(Collection<String> keys) Retrieves multiple cache entries stored under the given keys.final HttpCacheEntry
Retrieves the cache entry stored under the given key or null if no entry exists under that key.protected abstract CAS
getForUpdateCAS
(String storageKey) protected abstract T
getStorageObject
(CAS cas) final void
putEntry
(String key, HttpCacheEntry entry) Store a given cache entry under the given key.final void
removeEntry
(String key) Deletes/invalidates/removes any cache entries currently stored under the given key.protected abstract T
protected abstract void
protected abstract boolean
final void
updateEntry
(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:HttpCacheStorage
Store a given cache entry under the given key.- Specified by:
putEntry
in interfaceHttpCacheStorage
- Parameters:
key
- where in the cache to store the entryentry
- cached response to store- Throws:
ResourceIOException
-
getEntry
Description copied from interface:HttpCacheStorage
Retrieves the cache entry stored under the given key or null if no entry exists under that key.- Specified by:
getEntry
in interfaceHttpCacheStorage
- Parameters:
key
- cache key- Returns:
- an
HttpCacheEntry
ornull
if no entry exists - Throws:
ResourceIOException
-
removeEntry
Description copied from interface:HttpCacheStorage
Deletes/invalidates/removes any cache entries currently stored under the given key.- Specified by:
removeEntry
in interfaceHttpCacheStorage
- Parameters:
key
-- Throws:
ResourceIOException
-
updateEntry
public final void updateEntry(String key, HttpCacheCASOperation casOperation) throws HttpCacheUpdateException, ResourceIOException Description copied from interface:HttpCacheStorage
Atomically applies the given callback to processChallenge an existing cache entry under a given key.- Specified by:
updateEntry
in interfaceHttpCacheStorage
- Parameters:
key
- indicates which entry to modifycasOperation
- the CAS operation to perform.- Throws:
HttpCacheUpdateException
ResourceIOException
-
getEntries
public final Map<String,HttpCacheEntry> getEntries(Collection<String> keys) throws ResourceIOException Description copied from interface:HttpCacheStorage
Retrieves multiple cache entries stored under the given keys. Some implementations may use a single bulk operation to do the retrieval.- Specified by:
getEntries
in interfaceHttpCacheStorage
- Parameters:
keys
- cache keys- Returns:
- an map of
HttpCacheEntry
s. - Throws:
ResourceIOException
-