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 intmaxUpdateRetriesprivate 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 voiddelete(java.lang.String storageKey)protected abstract java.lang.StringdigestToStorageKey(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.HttpCacheEntrygetEntry(java.lang.String key)Retrieves the cache entry stored under the given key or null if no entry exists under that key.protected abstract CASgetForUpdateCAS(java.lang.String storageKey)protected abstract TgetStorageObject(CAS cas)voidputEntry(java.lang.String key, HttpCacheEntry entry)Store a given cache entry under the given key.voidremoveEntry(java.lang.String key)Deletes/invalidates/removes any cache entries currently stored under the given key.protected abstract Trestore(java.lang.String storageKey)protected abstract voidstore(java.lang.String storageKey, T storageObject)protected abstract booleanupdateCAS(java.lang.String storageKey, CAS cas, T storageObject)voidupdateEntry(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 ResourceIOExceptionDescription 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
public final HttpCacheEntry getEntry(java.lang.String key) throws ResourceIOException
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
public final void removeEntry(java.lang.String key) throws ResourceIOExceptionDescription copied from interface:HttpCacheStorageDeletes/invalidates/removes any cache entries currently stored under the given key.- Specified by:
removeEntryin interfaceHttpCacheStorage- Throws:
ResourceIOException
-
updateEntry
public final void updateEntry(java.lang.String key, HttpCacheCASOperation casOperation) throws HttpCacheUpdateException, ResourceIOExceptionDescription 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 java.util.Map<java.lang.String,HttpCacheEntry> getEntries(java.util.Collection<java.lang.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
-
-