android - Cache Strategy: If in LimitedAgeMemoryCache, load there, else load from web. Fall back to UnlimitedDiscCache on failure -


is possible above?

my scenario weather graphics urls remain same, while underlying image changes. here cases want cover: - inside same session of app (typically 2-5min), never want reload images web - after 15 minutes or so, image has changed, , if have cached version, want dump it. - when trying reload images while offline, image (including old) better no image, want show disc cache.

is setup possible? didn't seem obvious if feasible uil.

thanks great library!

i think solution you:

file cachedir = storageutils.getcachedirectory(context); // or other folder memorycacheaware<string, bitmap> memorycachecore            = new lrumemorycache(4 * 1024 * 1024); // or other implementation  memorycacheaware<string, bitmap> memorycache            = new limitedagememorycache<string, bitmap>(memorycachecore, 15 * 60); disccacheaware disccache = new limitedagedisccache(cachedir, 15 * 60); imageloaderconfiguration config = new imageloaderconfiguration.builder(context)         .memorycache(memorycache)         .disccache(disccache)         ...         .build(); 

upd: uil search needed image in memory cache @ first. uil search in disc cache. , downloads image network.

if use "limited age" memory cache or disc cache bitmap or image file deleted cache after timeout (actually deleted during search in cache). logic following:

  1. search bitmap in memory cache
    • needed bitmap there
      • bitmap added cache more specified time ago
        • delete memory cache, go step 2
      • bitmap added cache
        • get bitmap, display it. end.
    • no needed bitmap in cache, go step 2
  2. search image file in disc cache
    • needed image there
      • image added cache more specified time ago
        • delete disc cache, go step 3
      • image added cache
        • decode image bitmap, display it. end.
    • no needed image in cache, go step 3
  3. download image

don't forget enable caching (in display options, displayimageoptions).


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -