com.github.ignition.support.http.cache
Class HttpResponseCache
java.lang.Object
com.github.ignition.support.cache.AbstractCache<String,CachedHttpResponse.ResponseData>
com.github.ignition.support.http.cache.HttpResponseCache
- All Implemented Interfaces:
- Map<String,CachedHttpResponse.ResponseData>
public class HttpResponseCache
- extends AbstractCache<String,CachedHttpResponse.ResponseData>
Allows caching HTTP responses (only status code and payload at the moment) using the features
provided by AbstractCache. The key into the cache will be the request URL used to
retrieve the HTTP response in the first place.
- Author:
- Matthias Kaeppler
| Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
|
Constructor Summary |
HttpResponseCache(int initialCapacity,
long expirationInMinutes,
int maxConcurrentThreads)
|
| Methods inherited from class com.github.ignition.support.cache.AbstractCache |
clear, clear, containsKey, containsKeyInMemory, containsKeyOnDisk, containsValue, enableDiskCache, entrySet, get, getCachedFiles, getDiskCacheDirectory, isDiskCacheEnabled, isEmpty, keySet, put, putAll, remove, removeKey, setDiskCacheEnabled, size, values |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HttpResponseCache
public HttpResponseCache(int initialCapacity,
long expirationInMinutes,
int maxConcurrentThreads)
removeAllWithPrefix
public void removeAllWithPrefix(String urlPrefix)
getFileNameForKey
public String getFileNameForKey(String url)
- Description copied from class:
AbstractCache
- Only meaningful if disk caching is enabled. See
AbstractCache.enableDiskCache(android.content.Context, int). Turns a cache key
into the file name that will be used to persist the value to disk. Subclasses must implement
this.
- Specified by:
getFileNameForKey in class AbstractCache<String,CachedHttpResponse.ResponseData>
- Parameters:
url - the cache key
- Returns:
- the file name
readValueFromDisk
protected CachedHttpResponse.ResponseData readValueFromDisk(File file)
throws IOException
- Description copied from class:
AbstractCache
- Only meaningful if disk caching is enabled. See
AbstractCache.enableDiskCache(android.content.Context, int). Restores a value
previously persisted to the disk cache.
- Specified by:
readValueFromDisk in class AbstractCache<String,CachedHttpResponse.ResponseData>
- Parameters:
file - the file holding the cached value
- Returns:
- the cached value
- Throws:
IOException
writeValueToDisk
protected void writeValueToDisk(File file,
CachedHttpResponse.ResponseData data)
throws IOException
- Description copied from class:
AbstractCache
- Only meaningful if disk caching is enabled. See
AbstractCache.enableDiskCache(android.content.Context, int). Persists a value to
the disk cache.
- Specified by:
writeValueToDisk in class AbstractCache<String,CachedHttpResponse.ResponseData>
data - the cache value to persist
- Throws:
IOException
Copyright © 2012. All Rights Reserved.