java - Non-blocking file cache (BitmapLruCache) implementation? -
i trying create simple demo imageloader functionality android volley framework. constructor following:
public imageloader(requestqueue queue, imagecache imagecache) the problem imagecache. javadoc states:
simple cache adapter interface. if provided imageloader, used l1 cache before dispatch volley. implementations must not block. implementation lrucache recommended.
- what 'implementations must not block' in context means?
- is there example of non-blocking file cache (even non-android "pure" java) can use educate self how convert existing file cache non-blocking?
if no such exist - may negative implications of using existing implementation (just reading file):
public byte[] get(string filename) {
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;}
what 'implementations must not block' in context means?
in case, cannot disk i/o.
this level 1 (l1) cache, meaning designed return in matter of microseconds, not milliseconds or seconds. that's why advocate lrucache, memory cache.
is there example of non-blocking file cache (even non-android "pure" java) can use educate self how convert existing file cache non-blocking?
an l1 cache should not file cache.
what may negative implications of using existing implementation (just reading file)
an l1 cache should not file cache.
volley has integrated l2 file cache, named diskbasedcache, used caching http responses. can substitute own implementation of cache diskbasedcache if wish, , supply when create requestqueue.
Comments
Post a Comment