public class

BasicHttpCacheStorage

extends Object
implements HttpCacheStorage
java.lang.Object
   ↳ org.apache.http.impl.client.cache.BasicHttpCacheStorage

Class Overview

Basic HttpCacheStorage implementation backed by an instance of LinkedHashMap. In other words, cache entries and the cached response bodies are held in-memory. This cache does NOT deallocate resources associated with the cache entries; it is intended for use with HeapResource and similar. This is the default cache storage backend used by CachingHttpClient.

Summary

Public Constructors
BasicHttpCacheStorage(CacheConfig config)
Public Methods
synchronized HttpCacheEntry getEntry(String url)
Gets an entry from the cache, if it exists
synchronized void putEntry(String url, HttpCacheEntry entry)
Places a HttpCacheEntry in the cache
synchronized void removeEntry(String url)
Removes a HttpCacheEntry from the cache
synchronized void updateEntry(String url, HttpCacheUpdateCallback callback)
Atomically applies the given callback to update an existing cache entry under a given key.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.client.cache.HttpCacheStorage

Public Constructors

public BasicHttpCacheStorage (CacheConfig config)

Public Methods

public synchronized HttpCacheEntry getEntry (String url)

Gets an entry from the cache, if it exists

Parameters
url Url that is the cache key
Returns
  • HttpCacheEntry if one exists, or null for cache miss
Throws
IOException

public synchronized void putEntry (String url, HttpCacheEntry entry)

Places a HttpCacheEntry in the cache

Parameters
url Url to use as the cache key
entry HttpCacheEntry to place in the cache
Throws
IOException

public synchronized void removeEntry (String url)

Removes a HttpCacheEntry from the cache

Parameters
url Url that is the cache key
Throws
IOException

public synchronized void updateEntry (String url, HttpCacheUpdateCallback callback)

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

Parameters
url 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