Volley源码解析之数据结构

使用2个BlockingQueue, 用于存放请求队列, 和网络队列
public class CacheDispatcher extends Thread {

    /** The queue of requests coming in for triage. */
    private final BlockingQueue mCacheQueue;

    /** The queue of requests going out to the network. */
    private final BlockingQueue mNetworkQueue;


    /** The cache to read from. */
    private final Cache mCache;
Cache 是一个接口, 网络数据缓存到DiskBasedCache本地文件中
public interface Cache {

    public void put(String key, Entry entry);
    public Entry get(String key);
}
/**
 * Cache implementation that caches files directly onto the hard disk in the specified
 * directory. The default disk usage size is 5MB, but is configurable.
 */
public class DiskBasedCache implements Cache {
    private final Map mEntries =
            new LinkedHashMap(16, .75f, true);

    @Override
    public synchronized void initialize() {
    ...
    //初始化缓存文件
    FileInputStream fis = null;
    fis = new FileInputStream(file);
    ...
    }
}

-----------------DONE.-----------------------------------

你可能感兴趣的:(Volley源码解析之数据结构)