Skip to content

Files are deleted from Cache before Cache Policy rules were completed #18

@isaacfi

Description

@isaacfi

I tried to use all the Policies that you sugested in the documentation, but the files are only available for few seconds. Can you provide an example? I may forget something because the files are deleted when I tried to gets its content after almost 20 seconds.

class LastDownloadedCachePolicy extends CacheControlPolicy {
  LastDownloadedCachePolicy({int maxCount = 999})
      : super(
          maxCount: maxCount,
          minAge: Duration(days: 5),
          maxAge: Duration(days: 30),
        );

  @override
  String generateFilename({final String key, final String url}) => key;
}

var store = await CacheStore.getInstance(
        policy: LastDownloadedCachePolicy(), fetch: _fetchFile);
final file = await store.getFile('https://avatars.githubusercontent.com/u/647070?s=460&u=b85f224c333f371142df249b17012c5f8fe66cf2&v=4', key: 'myFile')

using Android adb shell:

lroot@vbox86p:/data/data/com.example.myApp/cache/cache_store # 
ls
root@vbox86p:/data/data/com.example.myApp/cache/cache_store # 

All the cache was cleared.

BR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions