org.apache.hc.client5.http.impl.cache

## 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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractSerializingAsyncCacheStorage(int maxUpdateRetries, HttpCacheEntrySerializer<T> serializer)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract Cancellable` | `bulkRestore(Collection<String> storageKeys, FutureCallback<Map<String,T>> callback)`
    `protected abstract Cancellable` | `delete(String storageKey, FutureCallback<Boolean> callback)`
    `protected abstract String` | `digestToStorageKey(String key)`
    `Cancellable` | `getEntries(Collection<String> keys, FutureCallback<Map<String,HttpCacheEntry>> callback)` Retrieves multiple cache entries stored under the given keys.
    `Cancellable` | `getEntry(String key, FutureCallback<HttpCacheEntry> callback)` Retrieves the cache entry stored under the given key or null if no entry exists under that key.
    `protected abstract Cancellable` | `getForUpdateCAS(String storageKey, FutureCallback<CAS> callback)`
    `protected abstract T` | `getStorageObject(CAS cas)`
    `Cancellable` | `putEntry(String key, HttpCacheEntry entry, FutureCallback<Boolean> callback)` Store a given cache entry under the given key.
    `Cancellable` | `removeEntry(String key, FutureCallback<Boolean> callback)` Deletes/invalidates/removes any cache entries currently stored under the given key.
    `protected abstract Cancellable` | `restore(String storageKey, FutureCallback<T> callback)`
    `protected abstract Cancellable` | `store(String storageKey, T storageObject, FutureCallback<Boolean> callback)`
    `protected abstract Cancellable` | `updateCAS(String storageKey, CAS cas, T storageObject, FutureCallback<Boolean> callback)`
    `Cancellable` | `updateEntry(String key, HttpCacheCASOperation casOperation, 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`

- - ### Constructor Detail

    - #### AbstractSerializingAsyncCacheStorage

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

  - ### Method Detail

    - #### digestToStorageKey

          protected abstract String digestToStorageKey(String key)

    - #### getStorageObject

          protected abstract T getStorageObject(CAS cas)
                                         throws ResourceIOException

      Throws:
        `ResourceIOException`

    - #### store

          protected abstract Cancellable store(String storageKey,
                                               T storageObject,
                                               FutureCallback<Boolean> callback)

    - #### restore

          protected abstract Cancellable restore(String storageKey,
                                                 FutureCallback<T> callback)

    - #### getForUpdateCAS

          protected abstract Cancellable getForUpdateCAS(String storageKey,
                                                         FutureCallback<CAS> callback)

    - #### updateCAS

          protected abstract Cancellable updateCAS(String storageKey,
                                                   CAS cas,
                                                   T storageObject,
                                                   FutureCallback<Boolean> callback)

    - #### delete

          protected abstract Cancellable delete(String storageKey,
                                                FutureCallback<Boolean> callback)

    - #### bulkRestore

          protected abstract Cancellable bulkRestore(Collection<String> storageKeys,
                                                     FutureCallback<Map<String,T>> callback)

    - #### putEntry

          public final Cancellable putEntry(String key,
                                            HttpCacheEntry entry,
                                            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 Cancellable getEntry(String key,
                                            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 Cancellable removeEntry(String key,
                                               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`
        `callback` - result callback

    - #### updateEntry

          public final Cancellable updateEntry(String key,
                                               HttpCacheCASOperation casOperation,
                                               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

    - #### getEntries

          public final Cancellable getEntries(Collection<String> keys,
                                              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

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.