Flutter cache manager library

4,380

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.)

Share:
4,380
ebg11
Author by

ebg11

Updated on December 10, 2022

Comments

  • ebg11
    ebg11 over 1 year

    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 :)

  • ebg11
    ebg11 about 5 years
    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?
  • Herbert Poul
    Herbert Poul about 5 years
    @ebg11 well right now, it does so at every access github.com/renefloor/flutter_cache_manager/blob/master/lib/s‌​rc/… .. (the cache manager creates a new sqlite connection for (basically) every cache access - github.com/renefloor/flutter_cache_manager/blob/master/lib/s‌​rc/… 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 :)
  • ebg11
    ebg11 about 5 years
    Appreciate your help :)