class RpkiRepositoryCleanupService {

    public long cleanupRpkiRepositories() {
        final InstantWithoutNanos unreferencedSince = InstantWithoutNanos.now().minus(cleanupGraceDuration);
        final Pair<Long, Long> deleted = Time.timed(() -> storage.writeTx(tx -> rpkiRepositories.deleteUnreferencedRepositories(tx, unreferencedSince)));
        log.info("Removed {} RPKI repositories that have not been referenced since {}, took {}ms", deleted.getLeft(), unreferencedSince, deleted.getRight());
        return deleted.getLeft();
    }

    public  RpkiRepositoryCleanupService(
            @Value("${rpki.validator.rpki.repository.cleanup.grace.duration:P7D}") Duration cleanupGraceDuration,
            Storage storage
    );

}