what is the best way to fix the size of the disc based cache ??android -volley

蹲街弑〆低调 提交于 2020-01-11 09:46:08

问题


1)The default implementation of the disc based cache present in android -volley is allocated a total memory of 5MB .

2)But the app Iam developing contains a lot of images .So I want to increase the size of the memory allocated by disc based cache .

3)So I want to increase the size of the cache ..I can simple do it by changing the value of DEFAULT_DISK_USAGE_BYTES inside Diskbasedcache.java file .

4)But I want to allocate memory based on the amount of space available in the disc ???Is there any way to implement it ??


回答1:


Few thoughts about Volley cache:

Using a disk based L1 cache may cause i/o blocking issues. Volley already has an implicit disk L2 cache. BitmapLruImageCache is a basic "least recently used" in memory cache implementation. It is fast and does not block I/O. This is the recommended approach.

I recommend you to play around this L1 cache for Volley

for tweaking the size have a look at this:

RequestQueue volleyQueue = Volley.newRequestQueue(this);
DiskBasedCache cache = new DiskBasedCache(getCacheDir(), 16 * 1024 * 1024);
volleyQueue = new RequestQueue(cache, new BasicNetwork(new HurlStack()));
volleyQueue.start();

Ref: Volley cache other ref about volley cache http://www.jayway.com/2013/10/04/image-caching-with-volley/



来源:https://stackoverflow.com/questions/21298692/what-is-the-best-way-to-fix-the-size-of-the-disc-based-cache-android-volley

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!