use of libcore.io.DiskLruCache in project android_frameworks_base by ParanoidAndroid.
the class HttpResponseCache method install.
/**
* Creates a new HTTP response cache and {@link ResponseCache#setDefault
* sets it} as the system default cache.
*
* @param directory the directory to hold cache data.
* @param maxSize the maximum size of the cache in bytes.
* @return the newly-installed cache
* @throws IOException if {@code directory} cannot be used for this cache.
* Most applications should respond to this exception by logging a
* warning.
*/
public static HttpResponseCache install(File directory, long maxSize) throws IOException {
HttpResponseCache installed = getInstalled();
if (installed != null) {
// don't close and reopen if an equivalent cache is already installed
DiskLruCache installedCache = installed.delegate.getCache();
if (installedCache.getDirectory().equals(directory) && installedCache.maxSize() == maxSize && !installedCache.isClosed()) {
return installed;
} else {
IoUtils.closeQuietly(installed);
}
}
HttpResponseCache result = new HttpResponseCache(directory, maxSize);
ResponseCache.setDefault(result);
return result;
}
use of libcore.io.DiskLruCache in project XobotOS by xamarin.
the class HttpResponseCache method install.
/**
* Creates a new HTTP response cache and {@link ResponseCache#setDefault
* sets it} as the system default cache.
*
* @param directory the directory to hold cache data.
* @param maxSize the maximum size of the cache in bytes.
* @return the newly-installed cache
* @throws IOException if {@code directory} cannot be used for this cache.
* Most applications should respond to this exception by logging a
* warning.
*/
public static HttpResponseCache install(File directory, long maxSize) throws IOException {
HttpResponseCache installed = getInstalled();
if (installed != null) {
// don't close and reopen if an equivalent cache is already installed
DiskLruCache installedCache = installed.delegate.getCache();
if (installedCache.getDirectory().equals(directory) && installedCache.maxSize() == maxSize && !installedCache.isClosed()) {
return installed;
} else {
IoUtils.closeQuietly(installed);
}
}
HttpResponseCache result = new HttpResponseCache(directory, maxSize);
ResponseCache.setDefault(result);
return result;
}
Aggregations