OkHttp 之缓存 Cache
主要有一个缓存类
带上一些问题来看
缓存谁?
缓存如何启用?
缓存采用哪些策略?
缓存的整个流程是?
缓存何时失效
强制缓存和对比缓存有啥区别?
Okhttp的CacheControl和缓存策略介绍
public final class Cache implements Closeable, Flushable
final DiskLruCache cache;
int writeSuccessCount;
int writeAbortCount;
private int networkCount;
private int hitCount;
private int requestCount;
缓存谁? 返回结果Response
用什么缓存策略 默认是 DiskLruCache cache;
缓存的两个构造方法
public Cache(File directory, long maxSize) {
this(directory, maxSize, FileSystem.SYSTEM);
}
Cache(File directory, long maxSize, FileSystem fileSystem) {
this.cache = DiskLruCache.create(fileSystem, directory, VERSION, ENTRY_COUNT, maxSize);
}
网友评论