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

1

4

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 ??

Modernism answered 23/1, 2014 at 3:19 Comment(0)
J
4

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/

Judi answered 23/1, 2014 at 4:18 Comment(4)
Hey ..Sorry I couldn't understand the difference between L1 and L2 cache ..The cache present in Diskbasedcache.java file is L1 or L2??Modernism
@Modernism use that code i displayed or Volley cache git link if you don't want learn theory part !Judi
is 16 the max size? @JudiMegaton
@scheychan There is no per-application limit for the cache directory. for more #2176343Judi

© 2022 - 2024 — McMap. All rights reserved.