Class AbstractSerializingAsyncCacheStorage<T,CAS>
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.AbstractSerializingAsyncCacheStorage<T,CAS>
-
- All Implemented Interfaces:
HttpAsyncCacheStorage
- Direct Known Subclasses:
AbstractBinaryAsyncCacheStorage
public abstract class AbstractSerializingAsyncCacheStorage<T,CAS> extends java.lang.Object implements HttpAsyncCacheStorage
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 AbstractSerializingAsyncCacheStorage(int maxUpdateRetries, HttpCacheEntrySerializer<T> serializer)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private voidattemptUpdateEntry(java.lang.String key, HttpCacheCASOperation casOperation, org.apache.hc.core5.concurrent.ComplexCancellable complexCancellable, java.util.concurrent.atomic.AtomicInteger count, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)protected abstract org.apache.hc.core5.concurrent.CancellablebulkRestore(java.util.Collection<java.lang.String> storageKeys, org.apache.hc.core5.concurrent.FutureCallback<java.util.Map<java.lang.String,T>> callback)protected abstract org.apache.hc.core5.concurrent.Cancellabledelete(java.lang.String storageKey, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)protected abstract java.lang.StringdigestToStorageKey(java.lang.String key)org.apache.hc.core5.concurrent.CancellablegetEntries(java.util.Collection<java.lang.String> keys, org.apache.hc.core5.concurrent.FutureCallback<java.util.Map<java.lang.String,HttpCacheEntry>> callback)Retrieves multiple cache entries stored under the given keys.org.apache.hc.core5.concurrent.CancellablegetEntry(java.lang.String key, org.apache.hc.core5.concurrent.FutureCallback<HttpCacheEntry> callback)Retrieves the cache entry stored under the given key or null if no entry exists under that key.protected abstract org.apache.hc.core5.concurrent.CancellablegetForUpdateCAS(java.lang.String storageKey, org.apache.hc.core5.concurrent.FutureCallback<CAS> callback)protected abstract TgetStorageObject(CAS cas)org.apache.hc.core5.concurrent.CancellableputEntry(java.lang.String key, HttpCacheEntry entry, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)Store a given cache entry under the given key.org.apache.hc.core5.concurrent.CancellableremoveEntry(java.lang.String key, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)Deletes/invalidates/removes any cache entries currently stored under the given key.protected abstract org.apache.hc.core5.concurrent.Cancellablerestore(java.lang.String storageKey, org.apache.hc.core5.concurrent.FutureCallback<T> callback)protected abstract org.apache.hc.core5.concurrent.Cancellablestore(java.lang.String storageKey, T storageObject, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)protected abstract org.apache.hc.core5.concurrent.CancellableupdateCAS(java.lang.String storageKey, CAS cas, T storageObject, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)org.apache.hc.core5.concurrent.CancellableupdateEntry(java.lang.String key, HttpCacheCASOperation casOperation, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)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
-
AbstractSerializingAsyncCacheStorage
public AbstractSerializingAsyncCacheStorage(int maxUpdateRetries, HttpCacheEntrySerializer<T> serializer)
-
-
Method Detail
-
digestToStorageKey
protected abstract java.lang.String digestToStorageKey(java.lang.String key)
-
getStorageObject
protected abstract T getStorageObject(CAS cas) throws ResourceIOException
- Throws:
ResourceIOException
-
store
protected abstract org.apache.hc.core5.concurrent.Cancellable store(java.lang.String storageKey, T storageObject, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)
-
restore
protected abstract org.apache.hc.core5.concurrent.Cancellable restore(java.lang.String storageKey, org.apache.hc.core5.concurrent.FutureCallback<T> callback)
-
getForUpdateCAS
protected abstract org.apache.hc.core5.concurrent.Cancellable getForUpdateCAS(java.lang.String storageKey, org.apache.hc.core5.concurrent.FutureCallback<CAS> callback)
-
updateCAS
protected abstract org.apache.hc.core5.concurrent.Cancellable updateCAS(java.lang.String storageKey, CAS cas, T storageObject, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)
-
delete
protected abstract org.apache.hc.core5.concurrent.Cancellable delete(java.lang.String storageKey, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)
-
bulkRestore
protected abstract org.apache.hc.core5.concurrent.Cancellable bulkRestore(java.util.Collection<java.lang.String> storageKeys, org.apache.hc.core5.concurrent.FutureCallback<java.util.Map<java.lang.String,T>> callback)
-
putEntry
public final org.apache.hc.core5.concurrent.Cancellable putEntry(java.lang.String key, HttpCacheEntry entry, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)Description copied from interface:HttpAsyncCacheStorageStore a given cache entry under the given key.- Specified by:
putEntryin interfaceHttpAsyncCacheStorage- Parameters:
key- where in the cache to store the entryentry- cached response to storecallback- result callback
-
getEntry
public final org.apache.hc.core5.concurrent.Cancellable getEntry(java.lang.String key, org.apache.hc.core5.concurrent.FutureCallback<HttpCacheEntry> callback)Description copied from interface:HttpAsyncCacheStorageRetrieves the cache entry stored under the given key or null if no entry exists under that key.- Specified by:
getEntryin interfaceHttpAsyncCacheStorage- Parameters:
key- cache keycallback- result callback- Returns:
- an
HttpCacheEntryornullif no entry exists
-
removeEntry
public final org.apache.hc.core5.concurrent.Cancellable removeEntry(java.lang.String key, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)Description copied from interface:HttpAsyncCacheStorageDeletes/invalidates/removes any cache entries currently stored under the given key.- Specified by:
removeEntryin interfaceHttpAsyncCacheStoragecallback- result callback
-
updateEntry
public final org.apache.hc.core5.concurrent.Cancellable updateEntry(java.lang.String key, HttpCacheCASOperation casOperation, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)Description copied from interface:HttpAsyncCacheStorageAtomically applies the given callback to processChallenge an existing cache entry under a given key.- Specified by:
updateEntryin interfaceHttpAsyncCacheStorage- Parameters:
key- indicates which entry to modifycasOperation- the CAS operation to perform.callback- result callback
-
attemptUpdateEntry
private void attemptUpdateEntry(java.lang.String key, HttpCacheCASOperation casOperation, org.apache.hc.core5.concurrent.ComplexCancellable complexCancellable, java.util.concurrent.atomic.AtomicInteger count, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Boolean> callback)
-
getEntries
public final org.apache.hc.core5.concurrent.Cancellable getEntries(java.util.Collection<java.lang.String> keys, org.apache.hc.core5.concurrent.FutureCallback<java.util.Map<java.lang.String,HttpCacheEntry>> callback)Description copied from interface:HttpAsyncCacheStorageRetrieves multiple cache entries stored under the given keys. Some implementations may use a single bulk operation to do the retrieval.- Specified by:
getEntriesin interfaceHttpAsyncCacheStorage- Parameters:
keys- cache keyscallback- result callback
-
-