问题描述
1)android -volley中基于磁盘的缓存的默认实现被分配了5MB的总内存.
1)The default implementation of the disc based cache present in android -volley is allocated a total memory of 5MB .
2)但是Iam开发的应用程序包含很多图像.因此,我想增加基于磁盘的缓存分配的内存大小.
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)因此,我想增加缓存的大小..我可以通过更改Diskbasedcache.java文件中的DEFAULT_DISK_USAGE_BYTES的值来简单地做到这一点.
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)但是我想根据光盘上的可用空间分配内存?有什么方法可以实现它?
4)But I want to allocate memory based on the amount of space available in the disc ???Is there any way to implement it ??
推荐答案
关于Volley缓存的一些想法:
Few thoughts about Volley cache:
使用基于磁盘的L1缓存可能会导致I/O阻塞问题. Volley已经具有隐式磁盘L2高速缓存. BitmapLruImageCache 是内存缓存实现中的基本最近最少使用".它速度很快,并且不会阻止I/O.这是推荐的方法.
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.
我建议您使用此 Volley的L1缓存
要调整大小,请看以下内容:
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();
参考:齐射缓存关于排球缓存的其他参考 http://www.jayway.com/2013/10/04/image-caching-with-volley/
Ref: Volley cacheother ref about volley cache http://www.jayway.com/2013/10/04/image-caching-with-volley/
这篇关于修复基于光盘的缓存大小的最佳方法是什么?android -volley的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!