purgeByBoundary method

  1. @override
Future<void> purgeByBoundary(
  1. BoundingBox boundingBox
)
override

Purges the cache whose Tiles intersects with the given boundingBox. Any bitmap which is fully or partially intersecting the given boundingBox will be purged.

Implementation

@override
Future<void> purgeByBoundary(BoundingBox boundingBox) async {
  // todo find a method to remove only affected files. For now we clear the whole cache
  int count = 0;
  for (String file in []..addAll(_files)) {
    //_log.info("  purging file from cache: $file");
    try {
      bool ok = await FileHelper.delete(file);
      if (ok) ++count;
    } catch (error) {
      _log.warning("purging $file was not successful, ignoring");
    }
  }
  _log.info("purged $count files from cache $renderkey");
  _files.clear();
}