如果让你去设计Volley的缓存功能,你要如何增大它的命中率

发布时间:2017-02-18 19:05:20 作者:哈尔滨app开发公司哈尔滨app开发app开发公司

下面是DiskBasedCache pruneIfNeeded()源码:private void pruneIfNeeded(int neededSpace) {if ((mTotalSize + neededSpace) < m

 下面是DiskBasedCache#pruneIfNeeded()源码:
private void pruneIfNeeded(int neededSpace) {
    if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes) {
        return;
    }
 
    long before = mTotalSize;
    int prunedFiles = 0;
    long startTime = SystemClock.elapsedRealtime();
 
    Iterator<map.entry<string, cacheheader="">> iterator = mEntries.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<string, cacheheader=""> entry = iterator.next();
        CacheHeader e = entry.getValue();
        boolean deleted = getFileForKey(e.key).delete();
        if (deleted) {
            mTotalSize -= e.size;
        } else {
    //print log
        }
        iterator.remove();
        prunedFiles++;
    &nbs
评论

相关阅读



联系我们