<?php

namespace App\Console\Commands;

use App\Services\CacheService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;

class ClearStorefrontCache extends Command
{
    protected $signature = 'cache:clear-storefront';

    protected $description = 'Forget homepage/product cache keys without Redis FLUSHDB (safe on restricted Redis)';

    public function handle(CacheService $cacheService): int
    {
        $cacheService->clearHomepageCache();
        $cacheService->clearProductCache();
        Cache::forget('homepage.announcements');

        $this->info('Storefront cache keys cleared (no FLUSHDB).');

        return self::SUCCESS;
    }
}
