public final class HttpResponseCache extends ResponseCache
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
close() |
Disables a cache without changing the data in it.
|
void |
delete() |
Disables a cache and deletes the data in it.
|
void |
flush() |
Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request.
|
CacheResponse |
get(URI uri,
String rqstMethod,
Map<String,List<String>> rqstHeaders) |
Retrieve the cached response based on the requesting uri,
request method and request headers.
|
int |
getHitCount() |
Obtains the number of times the cached data is accessed.
|
static HttpResponseCache |
getInstalled() |
Obtains the
HttpResponseCache object. |
long |
getMaxSize() |
Obtains the maximum number of bytes in a cache.
|
int |
getNetworkCount() |
Obtains the number of HTTP requests.
|
int |
getRequestCount() |
Obtains the number of HTTP requests after a cache is created.
|
long |
getSize() |
Obtains the number of bytes in a cache.
|
static HttpResponseCache |
install(File directory,
long size) |
Creates a default
HttpResponseCache object to store the responses of HTTP access requests. |
CacheRequest |
put(URI uri,
URLConnection conn) |
The protocol handler calls this method after a resource has
been retrieved, and the ResponseCache must decide whether or
not to store the resource in its cache.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDefault, setDefaultpublic static HttpResponseCache getInstalled()
HttpResponseCache object.HttpResponseCache object.public static HttpResponseCache install(File directory, long size) throws IOException
HttpResponseCache object to store the responses of HTTP access requests.directory - Indicates the directory for storing the cached data.size - Indicates the maximum size of the cached data.IOException - Throws this exception if the cache cannot be accessed.public CacheResponse get(URI uri, String rqstMethod, Map<String,List<String>> rqstHeaders) throws IOException
ResponseCacheget 在类中 ResponseCacheuri - a URI used to reference the requested
network resourcerqstMethod - a String representing the request
methodrqstHeaders - - a Map from request header
field names to lists of field values representing
the current request headersCacheResponse instance if available
from cache, or null otherwiseIOException - if an I/O error occursURLConnection.setUseCaches(boolean),
URLConnection.getUseCaches(),
URLConnection.setDefaultUseCaches(boolean),
URLConnection.getDefaultUseCaches()public CacheRequest put(URI uri, URLConnection conn) throws IOException
ResponseCacheput 在类中 ResponseCacheuri - a URI used to reference the requested
network resourceconn - - a URLConnection instance that is used to fetch
the response to be cachedCacheRequest for recording the
response to be cached. Null return indicates that
the caller does not intend to cache the response.IOException - if an I/O error occurspublic long getSize()
throws IOException
IOException - Throws this exception if the cache cannot be accessed.public long getMaxSize()
public void flush()
throws IOException
IOException - Throws this exception if the cache cannot be accessed.public int getNetworkCount()
public int getHitCount()
public int getRequestCount()
public void close()
throws IOException
IOException - Throws this exception if the cache cannot be accessed.public void delete()
throws IOException
IOException - Throws this exception if the cache cannot be accessed.