class SaveSpaceUsageToFile implements SpaceUsagePersistence {

  @Override
  public OptionalLong load() {
    try (Scanner sc = new Scanner(file, UTF_8.name())) {
      // Get the recorded value from the file.
      if (!sc.hasNextLong()) {
        LOG.info("Cached usage info in {} has no value", file);
        return OptionalLong.empty();
      }
      long cachedValue = sc.nextLong();

      // Get the recorded time from the file.
      if (!sc.hasNextLong()) {
        LOG.info("Cached usage info in {} has no time", file);
        return OptionalLong.empty();
      }

      Instant time = Instant.ofEpochMilli(sc.nextLong());
      if (isExpired(time)) {
        LOG.info("Cached usage info in {} is expired: {} ", file, time);
        return OptionalLong.empty();
      }

      LOG.info("Cached usage info found in {}: {} at {}", file, cachedValue,
          time);

      return OptionalLong.of(cachedValue);
    } catch (FileNotFoundException e) {
      LOG.info("Cached usage info file {} not found", file);
      return OptionalLong.empty();
    }
  }

  public  SaveSpaceUsageToFile(File file, Duration expiry);

}