PaulNguyenBlockchain / android-query

Automatically exported from code.google.com/p/android-query
0 stars 0 forks source link

Priority of cached files [Enhancment] #129

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Library is lacking priority of cached files.

For example I have 2 types of images:

1 - small icons - map markers
2 - very large images

I want them both be cached but images type 1 never be removed as they occupy 
only 1MB space and never change.

I suggest adding following method:

.cachePriortiy(Integer priority);

When reaching limit of space 1st all the oldest files with lower priority would 
be removed, and only when that would be not enough higher priority files would 
be deleted.

Original issue reported on code.google.com by darck...@gmail.com on 27 Mar 2013 at 3:06

GoogleCodeExporter commented 8 years ago
it seems that there is undocummented parameter policy(CACHE_PERSISTENT)

Original comment by darck...@gmail.com on 13 Jun 2013 at 9:16

GoogleCodeExporter commented 8 years ago
So there are 2 policies: 

    public static final int CACHE_DEFAULT = 0;
    public static final int CACHE_PERSISTENT = 1;

I added 1 more:

    public static final int CACHE_TEMPORARY = 2;

https://github.com/Malachiasz/androidquery/commits/master

AQuery works little different than I was thinking. Expiry parameter of ajax() 
means only that file should be fetched from the Internet when it expired. It is 
not removed from the disk when it expired. Files are removed based on last time 
they were used.

my CACHE_TEMPORARY causes every file downloaded with this policy to be removed 
as soon as AQUtility.cleanCacheAsync() is invoked, regardless of cache trigger 
parameters. 

Original comment by darck...@gmail.com on 13 Jun 2013 at 12:57