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 java.lang.Object implements HttpCacheStorage
Abstract cache backend for serialized objects capable of CAS (compare-and-swap) updates.- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description private int
maxUpdateRetries
private HttpCacheEntrySerializer<T>
serializer
-
Constructor Summary
Constructors Constructor Description AbstractSerializingCacheStorage(int maxUpdateRetries, HttpCacheEntrySerializer<T> serializer)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.util.Map<java.lang.String,T>
bulkRestore(java.util.Collection<java.lang.String> storageKeys)
protected abstract void
delete(java.lang.String storageKey)
protected abstract java.lang.String
digestToStorageKey(java.lang.String key)
java.util.Map<java.lang.String,HttpCacheEntry>
getEntries(java.util.Collection<java.lang.String> keys)
Retrieves multiple cache entries stored under the given keys.HttpCacheEntry
getEntry(java.lang.String key)
Retrieves the cache entry stored under the given key or null if no entry exists under that key.protected abstract CAS
getForUpdateCAS(java.lang.String storageKey)
protected abstract T
getStorageObject(CAS cas)
void
putEntry(java.lang.String key, HttpCacheEntry entry)
Store a given cache entry under the given key.void
removeEntry(java.lang.String key)
Deletes/invalidates/removes any cache entries currently stored under the given key.protected abstract T
restore(java.lang.String storageKey)
protected abstract void
store(java.lang.String storageKey, T storageObject)
protected abstract boolean
updateCAS(java.lang.String storageKey, CAS cas, T storageObject)
void
updateEntry(java.lang.String key, HttpCacheCASOperation casOperation)
Atomically applies the given callback to processChallenge an existing cache entry under a given key.
-
-
-
Field Detail
-
maxUpdateRetries
private final int maxUpdateRetries
-
serializer
private final HttpCacheEntrySerializer<T> serializer
-
-
Constructor Detail
-
AbstractSerializingCacheStorage
public AbstractSerializingCacheStorage(int maxUpdateRetries, HttpCacheEntrySerializer<T> serializer)
-
-
Method Detail
-
digestToStorageKey
protected abstract java.lang.String digestToStorageKey(java.lang.String key)
-
store
protected abstract void store(java.lang.String storageKey, T storageObject) throws ResourceIOException
- Throws:
ResourceIOException
-
restore
protected abstract T restore(java.lang.String storageKey) throws ResourceIOException
- Throws:
ResourceIOException
-
getForUpdateCAS
protected abstract CAS getForUpdateCAS(java.lang.String storageKey) throws ResourceIOException
- Throws:
ResourceIOException
-
getStorageObject
protected abstract T getStorageObject(CAS cas) throws ResourceIOException
- Throws:
ResourceIOException
-
updateCAS
protected abstract boolean updateCAS(java.lang.String storageKey, CAS cas, T storageObject) throws ResourceIOException
- Throws:
ResourceIOException
-
delete
protected abstract void delete(java.lang.String storageKey) throws ResourceIOException
- Throws:
ResourceIOException
-
bulkRestore
protected abstract java.util.Map<java.lang.String,T> bulkRestore(java.util.Collection<java.lang.String> storageKeys) throws ResourceIOException
- Throws:
ResourceIOException
-
putEntry
public final void putEntry(java.lang.String key, HttpCacheEntry entry) throws ResourceIOException
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
public final HttpCacheEntry getEntry(java.lang.String key) throws ResourceIOException
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
public final void removeEntry(java.lang.String key) throws ResourceIOException
Description copied from interface:HttpCacheStorage
Deletes/invalidates/removes any cache entries currently stored under the given key.- Specified by:
removeEntry
in interfaceHttpCacheStorage
- Throws:
ResourceIOException
-
updateEntry
public final void updateEntry(java.lang.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 java.util.Map<java.lang.String,HttpCacheEntry> getEntries(java.util.Collection<java.lang.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
-
-