<?php

namespace Bastion\Tasks;

use DateInterval;
use Openguru\OpenCartFramework\Cache\CacheInterface;
use Openguru\OpenCartFramework\MaintenanceTasks\BaseMaintenanceTask;
use Psr\Log\LoggerInterface;

class CachePruneTask extends BaseMaintenanceTask
{
    private CacheInterface $cache;

    public function __construct(LoggerInterface $logger, CacheInterface $cache)
    {
        parent::__construct($logger);

        $this->cache = $cache;
    }

    public function handle(): void
    {
        $this->cache->prune();
    }

    public function interval(): ?DateInterval
    {
        return new DateInterval('P1D');
    }
}
