私はたくさんの(リモート)画像でリストビューを表示しようとしています。私は仕事にボレーを使用しようとしています。ボレーとビットマップキャッシング
ボレーはやや効いていますが、十分ではありません。 ImageLoader.getにボレーは、次のコードを有する。
final String cacheKey = getCacheKey(requestUrl, maxWidth, maxHeight);
// Try to look up the request in the cache of remote images.
Bitmap cachedBitmap = mCache.getBitmap(cacheKey);
if (cachedBitmap != null) {
// Return the cached bitmap.
ImageContainer container = new ImageContainer(cachedBitmap, requestUrl, null, null);
imageListener.onResponse(container, true);
return container;
}
しかし、getCacheKeyこのようなキーを生成する:
/**
* Creates a cache key for use with the L1 cache.
* @param url The URL of the request.
* @param maxWidth The max-width of the output.
* @param maxHeight The max-height of the output.
*/
private static String getCacheKey(String url, int maxWidth, int maxHeight) {
return new StringBuilder(url.length() + 12).append("#W").append(maxWidth)
.append("#H").append(maxHeight).append(url).toString();
}
すなわち、キーに幅と高さのようないくつかの「メタデータ」を付加します。
このキーは決してでヒットし、イメージがL1キャッシュにない場合は、オンラインでフェッチされます。イメージをオンラインで取得すると、ディスクキャッシュに保存されますが、VolleyはURL(およびURLのみ)をキーとして保存します。
これが期待どおりの動作ですか?何か不足していますか?
あなたの応答のヘッダに依存する可能性があります。 – njzk2
なぜ、ボレーはヒットしないのですか? – iamrelos
[droidQuery](http://bit.ly/droidquery)を使用して、非同期の快適なリクエスト(Ajax)を完了し、キャッシュの管理を容易にすることができます(キャッシュされたオブジェクトを保持するかどうか、および保持する期間)。 – Phil