public class AndroidShimResponseCache extends ResponseCache
ResponseCache
with stats.| Modifier and Type | Method and Description |
|---|---|
void |
close()
Uninstalls the cache and releases any active resources.
|
static AndroidShimResponseCache |
create(File directory,
long maxSize) |
void |
delete()
Uninstalls the cache and deletes all of its stored contents.
|
void |
flush()
Force buffered operations to the filesystem.
|
CacheResponse |
get(URI uri,
String requestMethod,
Map<String,List<String>> requestHeaders)
Returns the cached response corresponding to the given request.
|
Cache |
getCache() |
int |
getHitCount()
Returns the number of HTTP requests whose response was provided by the
cache.
|
int |
getNetworkCount()
Returns the number of HTTP requests that required the network to either
supply a response or validate a locally cached response.
|
int |
getRequestCount()
Returns the total number of HTTP requests that were made.
|
boolean |
isEquivalent(File directory,
long maxSize) |
long |
maxSize()
Returns the maximum number of bytes that this cache should use to store
its data.
|
CacheRequest |
put(URI uri,
URLConnection urlConnection)
Allows the protocol handler to cache data after retrieving resources.
|
long |
size()
Returns the number of bytes currently being used to store the values in
this cache.
|
getDefault, setDefaultpublic static AndroidShimResponseCache create(File directory, long maxSize) throws IOException
IOExceptionpublic boolean isEquivalent(File directory, long maxSize)
public Cache getCache()
public CacheResponse get(URI uri, String requestMethod, Map<String,List<String>> requestHeaders) throws IOException
ResponseCacheget in class ResponseCacheuri - the request URI.requestMethod - the request method.requestHeaders - a map of request headers.CacheResponse object if the request is available in the cache
or null otherwise.IOException - if an I/O error occurs while getting the cached data.public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException
ResponseCacheResponseCache decides whether the resource data should be cached
or not. If so, this method returns a CacheRequest to write the
resource data to. Otherwise, this method returns null.put in class ResponseCacheuri - the reference to the requested resource.urlConnection - the connection to fetch the response.null otherwise.IOException - if an I/O error occurs while adding the resource.public long size()
throws IOException
maxSize() if a background
deletion is pending.IOExceptionpublic long maxSize()
public void flush()
throws IOException
IOExceptionpublic int getNetworkCount()
public int getHitCount()
GET requests that were
validated over the network.public int getRequestCount()
public void close()
throws IOException
IOExceptionpublic void delete()
throws IOException
IOException