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

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

      public abstract class AbstractSerializingCacheStorage<T,CAS>
      extends Object
      implements HttpCacheStorage

  Abstract cache backend for serialized objects capable of CAS (compare-and-swap) updates.
  Since:
    5.0

- - ### Constructor Summary

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

  - ### Method Summary

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

    - #### AbstractSerializingCacheStorage

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

  - ### Method Detail

    - #### digestToStorageKey

          protected abstract String digestToStorageKey(String key)

    - #### store

          protected abstract void store(String storageKey,
                   T storageObject)
                                 throws ResourceIOException

      Throws:
        `ResourceIOException`

    - #### restore

          protected abstract T restore(String storageKey)
                                throws ResourceIOException

      Throws:
        `ResourceIOException`

    - #### getForUpdateCAS

          protected abstract CAS getForUpdateCAS(String storageKey)
                                          throws ResourceIOException

      Throws:
        `ResourceIOException`

    - #### getStorageObject

          protected abstract T getStorageObject(CAS cas)
                                         throws ResourceIOException

      Throws:
        `ResourceIOException`

    - #### updateCAS

          protected abstract boolean updateCAS(String storageKey,
                          CAS cas,
                          T storageObject)
                                        throws ResourceIOException

      Throws:
        `ResourceIOException`

    - #### delete

          protected abstract void delete(String storageKey)
                                  throws ResourceIOException

      Throws:
        `ResourceIOException`

    - #### bulkRestore

          protected abstract Map<String,T> bulkRestore(Collection<String> storageKeys)
                                                throws ResourceIOException

      Throws:
        `ResourceIOException`

    - #### putEntry

          public final void putEntry(String key,
                      HttpCacheEntry entry)
                              throws ResourceIOException

      Description copied from interface: `HttpCacheStorage`
      Store a given cache entry under the given key.
      Specified by:
        `putEntry` in interface `HttpCacheStorage`
      Parameters:
        `key` - where in the cache to store the entry
        `entry` - cached response to store
      Throws:
        `ResourceIOException`

    - #### getEntry

          public final HttpCacheEntry getEntry(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 interface `HttpCacheStorage`
      Parameters:
        `key` - cache key
      Returns:
        an `HttpCacheEntry` or `null` if no entry exists
      Throws:
        `ResourceIOException`

    - #### removeEntry

          public final void removeEntry(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 interface `HttpCacheStorage`
      Throws:
        `ResourceIOException`

    - #### updateEntry

          public final void updateEntry(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 interface `HttpCacheStorage`
      Parameters:
        `key` - indicates which entry to modify
        `casOperation` - the CAS operation to perform.
      Throws:
        `HttpCacheUpdateException`
        `ResourceIOException`

    - #### getEntries

          public final Map<String,HttpCacheEntry> getEntries(Collection<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 interface `HttpCacheStorage`
      Parameters:
        `keys` - cache keys
      Returns:
        an map of `HttpCacheEntry`s.
      Throws:
        `ResourceIOException`

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