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 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 final int
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    attemptUpdateEntry(String key, HttpCacheCASOperation casOperation, org.apache.hc.core5.concurrent.ComplexCancellable complexCancellable, AtomicInteger count, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
     
    protected abstract org.apache.hc.core5.concurrent.Cancellable
    bulkRestore(Collection<String> storageKeys, org.apache.hc.core5.concurrent.FutureCallback<Map<String,T>> callback)
     
    protected abstract org.apache.hc.core5.concurrent.Cancellable
    delete(String storageKey, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
     
    protected abstract String
     
    final org.apache.hc.core5.concurrent.Cancellable
    getEntries(Collection<String> keys, org.apache.hc.core5.concurrent.FutureCallback<Map<String,HttpCacheEntry>> callback)
    Retrieves multiple cache entries stored under the given keys.
    final org.apache.hc.core5.concurrent.Cancellable
    getEntry(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.Cancellable
    getForUpdateCAS(String storageKey, org.apache.hc.core5.concurrent.FutureCallback<CAS> callback)
     
    protected abstract T
     
    final org.apache.hc.core5.concurrent.Cancellable
    putEntry(String key, HttpCacheEntry entry, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
    Store a given cache entry under the given key.
    final org.apache.hc.core5.concurrent.Cancellable
    removeEntry(String key, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
    Deletes/invalidates/removes any cache entries currently stored under the given key.
    protected abstract org.apache.hc.core5.concurrent.Cancellable
    restore(String storageKey, org.apache.hc.core5.concurrent.FutureCallback<T> callback)
     
    protected abstract org.apache.hc.core5.concurrent.Cancellable
    store(String storageKey, T storageObject, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
     
    protected abstract org.apache.hc.core5.concurrent.Cancellable
    updateCAS(String storageKey, CAS cas, T storageObject, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
     
    final org.apache.hc.core5.concurrent.Cancellable
    updateEntry(String key, HttpCacheCASOperation casOperation, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
    Atomically applies the given callback to processChallenge an existing cache entry under a given key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AbstractSerializingAsyncCacheStorage

      public AbstractSerializingAsyncCacheStorage(int maxUpdateRetries, HttpCacheEntrySerializer<T> serializer)
  • Method Details

    • digestToStorageKey

      protected abstract String digestToStorageKey(String key)
    • getStorageObject

      protected abstract T getStorageObject(CAS cas) throws ResourceIOException
      Throws:
      ResourceIOException
    • store

      protected abstract org.apache.hc.core5.concurrent.Cancellable store(String storageKey, T storageObject, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
    • restore

      protected abstract org.apache.hc.core5.concurrent.Cancellable restore(String storageKey, org.apache.hc.core5.concurrent.FutureCallback<T> callback)
    • getForUpdateCAS

      protected abstract org.apache.hc.core5.concurrent.Cancellable getForUpdateCAS(String storageKey, org.apache.hc.core5.concurrent.FutureCallback<CAS> callback)
    • updateCAS

      protected abstract org.apache.hc.core5.concurrent.Cancellable updateCAS(String storageKey, CAS cas, T storageObject, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
    • delete

      protected abstract org.apache.hc.core5.concurrent.Cancellable delete(String storageKey, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
    • bulkRestore

      protected abstract org.apache.hc.core5.concurrent.Cancellable bulkRestore(Collection<String> storageKeys, org.apache.hc.core5.concurrent.FutureCallback<Map<String,T>> callback)
    • putEntry

      public final org.apache.hc.core5.concurrent.Cancellable putEntry(String key, HttpCacheEntry entry, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
      Description copied from interface: HttpAsyncCacheStorage
      Store a given cache entry under the given key.
      Specified by:
      putEntry in interface HttpAsyncCacheStorage
      Parameters:
      key - where in the cache to store the entry
      entry - cached response to store
      callback - result callback
    • getEntry

      public final org.apache.hc.core5.concurrent.Cancellable getEntry(String key, org.apache.hc.core5.concurrent.FutureCallback<HttpCacheEntry> callback)
      Description copied from interface: HttpAsyncCacheStorage
      Retrieves the cache entry stored under the given key or null if no entry exists under that key.
      Specified by:
      getEntry in interface HttpAsyncCacheStorage
      Parameters:
      key - cache key
      callback - result callback
      Returns:
      an HttpCacheEntry or null if no entry exists
    • removeEntry

      public final org.apache.hc.core5.concurrent.Cancellable removeEntry(String key, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
      Description copied from interface: HttpAsyncCacheStorage
      Deletes/invalidates/removes any cache entries currently stored under the given key.
      Specified by:
      removeEntry in interface HttpAsyncCacheStorage
      Parameters:
      key -
      callback - result callback
    • updateEntry

      public final org.apache.hc.core5.concurrent.Cancellable updateEntry(String key, HttpCacheCASOperation casOperation, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
      Description copied from interface: HttpAsyncCacheStorage
      Atomically applies the given callback to processChallenge an existing cache entry under a given key.
      Specified by:
      updateEntry in interface HttpAsyncCacheStorage
      Parameters:
      key - indicates which entry to modify
      casOperation - the CAS operation to perform.
      callback - result callback
    • attemptUpdateEntry

      private void attemptUpdateEntry(String key, HttpCacheCASOperation casOperation, org.apache.hc.core5.concurrent.ComplexCancellable complexCancellable, AtomicInteger count, org.apache.hc.core5.concurrent.FutureCallback<Boolean> callback)
    • getEntries

      public final org.apache.hc.core5.concurrent.Cancellable getEntries(Collection<String> keys, org.apache.hc.core5.concurrent.FutureCallback<Map<String,HttpCacheEntry>> callback)
      Description copied from interface: HttpAsyncCacheStorage
      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 interface HttpAsyncCacheStorage
      Parameters:
      keys - cache keys
      callback - result callback