<?php

declare(strict_types=1);

namespace App\Framework\Cache\Events;

use App\Framework\Cache\CacheKey;
use App\Framework\Core\ValueObjects\Timestamp;

/**
 * Event fired when a key is deleted from cache
 */
final readonly class CacheDelete
{
    public function __construct(
        public CacheKey $key,
        public bool $success,
        public Timestamp $timestamp
    ) {
    }

    /**
     * Create a new CacheDelete event with the current timestamp
     */
    public static function create(CacheKey $key, bool $success): self
    {
        return new self($key, $success, Timestamp::now());
    }
}
