class BuildCacheUtils {

    @VisibleForTesting
    static boolean shouldRunCacheEviction(
            @NonNull FileCache buildCache, @NonNull Duration cacheEvictionInterval) {
        // Find out the last time cache eviction was run
        File markerFile = new File(buildCache.getCacheDirectory(), CACHE_EVICTION_MARKER_FILE_NAME);
        long lastEvictionTimestamp = markerFile.lastModified();
        boolean shouldRunCacheEviction =
                lastEvictionTimestamp == 0 /* The marker file does not yet exist */
                        || Duration.ofMillis(System.currentTimeMillis() - lastEvictionTimestamp)
                                        .compareTo(cacheEvictionInterval)
                                >= 0;
        if (shouldRunCacheEviction) {
            updateMarkerFile(markerFile);
        }
        return shouldRunCacheEviction;
    }

}