# HttpCacheStorage (Apache HttpComponents Client 4.5.14 API)
Date: 2022-11-30

org.apache.http.client.cache

## Interface HttpCacheStorage

All Known Implementing Classes:
  BasicHttpCacheStorage, EhcacheHttpCacheStorage, ManagedHttpCacheStorage, MemcachedHttpCacheStorage

    public interface HttpCacheStorage

New storage backends should implement this `HttpCacheStorage` interface. They can then be plugged into the existing `CachingHttpClient` implementation.

Since:
  4.1

### Method Summary

Methods
`HttpCacheEntry` `getEntry(String key)` Retrieves the cache entry stored under the given key or null if no entry exists under that key.
`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.
`void` `updateEntry(String key, HttpCacheUpdateCallback callback)` Atomically applies the given callback to update an existing cache entry under a given key.

### Method Detail

#### putEntry

    void putEntry(String key,
                HttpCacheEntry entry)
                  throws IOException

Store a given cache entry under the given key.

Parameters:
  `key` - where in the cache to store the entry
  `entry` - cached response to store
Throws:
  `IOException`

#### getEntry

    HttpCacheEntry getEntry(String key)
                            throws IOException

Retrieves the cache entry stored under the given key or null if no entry exists under that key.

Parameters:
  `key` - cache key
Returns:
  an `HttpCacheEntry` or `null` if no entry exists
Throws:
  `IOException`

#### removeEntry

    void removeEntry(String key)
                     throws IOException

Deletes/invalidates/removes any cache entries currently stored under the given key.

Parameters:
  `key` -
Throws:
  `IOException`

#### updateEntry

    void updateEntry(String key,
                   HttpCacheUpdateCallback callback)
                     throws IOException,
                            HttpCacheUpdateException

Atomically applies the given callback to update an existing cache entry under a given key.

Parameters:
  `key` - indicates which entry to modify
  `callback` - performs the update; see `HttpCacheUpdateCallback` for details, but roughly the callback expects to be handed the current entry and will return the new value for the entry.
Throws:
  `IOException`
  `HttpCacheUpdateException`