1

I am using this library https://pub.dartlang.org/packages/flutter_cache_manager#-readme-tab- and I have 2 questions. Firstly, it is unclear to me whether the getFile(url) function automatically caches the file that is returned or whether I must call putFile() after it is returned.

Secondly, I see that you can override BaseCacheManager to set a maxAgeCacheObject. Does the OS automatically delete files that have expired or must I make sure they are cleaned.

Thanks for the help :)

1 Answer 1

1

ad 1) The getFile(url) method will "automatically" cache the result. The putFile() method is only available to eagerly precache data.

ad 2) Both, You should make sure you have a reasonable upper limit. But since files are stored in a temporary directory which the OS is allowed to delete, the files will be removed if the device runs out of storage. --- FWIW - No, the OS does not remove files which are too old, but the cache manager will remove objects which are older than maxAgeCacheObject. (The OS does not know about how old a file can be, it might start deleting the oldest files first, but there is no guarantee for this.)

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your answer herbert. Could you tell me when the cache manager removes files with an age greater that the maxAgeCacheObject... For example does it do this when the singleton is initialized for the first time?
@ebg11 well right now, it does so at every access github.com/renefloor/flutter_cache_manager/blob/master/lib/src/… .. (the cache manager creates a new sqlite connection for (basically) every cache access - github.com/renefloor/flutter_cache_manager/blob/master/lib/src/… which imo is pretty strange, especially since it's afaik best practice to never close sqlite on mobile stackoverflow.com/a/44578432/109219 but that's somehow a bit off topic :)
Appreciate your help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.