flutter_cache_store
flutter_cache_store copied to clipboard
Files are deleted from Cache before Cache Policy rules were completed
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.
var store
supposes to be an instance only created once when your app starting up. As long as you create another instance with the same namespace, it will override previous one and could clear the cache if not persistented.