invalidateCachedStatisticsAsync method

Future<void> invalidateCachedStatisticsAsync({
  1. List<String>? statTypes = const ['length', 'size'],
})

Remove the cached statistics asynchronously

For synchronous version, see invalidateCachedStatistics.

statTypes dictates the types of statistics to remove, defaulting to only 'length' and 'size'. Set to null to remove all types.

Implementation

Future<void> invalidateCachedStatisticsAsync({
  List<String>? statTypes = const [
    'length',
    'size',
  ],
}) =>
    Future.wait(
      (statTypes ??
              [
                'length',
                'size',
                'cacheHits',
                'cacheMisses',
              ])
          .map((e) async {
        final File file = _access.stats >>> '$e.cache';
        return await file.exists() ? file.delete() : null;
      }),
    );