我正在尝试为Android Volley Framework的ImageLoader功能创建一个简单演示。构造函数如下:非阻塞文件缓存(BitmapLruCache)的实现?
public ImageLoader(RequestQueue queue, ImageCache imageCache)
问题出在ImageCache
。它的JavaDoc状态:
简单缓存适配器接口。如果提供给ImageLoader,它将在发送到Volley之前用作L1缓存。实现 不得阻塞。推荐使用LruCache实施。
- 究竟是什么“实现必须不能阻止”在这种情况下意味着什么?
- 有无阻塞文件缓存(甚至非Android,但“纯” JAVA),我可以用它来教育我自己如何转换我现有的文件缓存是不可阻挡的例子吗?
如果没有这样的存在 - 什么可能是利用我现有的实施是(只是从文件中读取)的负面影响:
公共字节[]得到(字符串文件名){
byte[] ret = null; if (filesCache.containsKey(filename)) { FileInfo fi = filesCache.get(filename); BufferedInputStream input; String path = cacheDir + "/" + fi.getStorageFilename(); try { File file = new File(path); if (file.exists()) { input = new BufferedInputStream(new FileInputStream(file)); ret = IOUtils.toByteArray(input); input.close(); } else { KhandroidLog.e("Cannot find file " + path); } } catch (FileNotFoundException e) { filesCache.remove(filename); KhandroidLog.e("Cannot find file: " + path); } catch (IOException e) { KhandroidLog.e(e.getMessage()); } } return ret;
}