<?php

namespace Archive\Optimized;

/**
 * Cache-Strategien für Templates
 */
enum CacheStrategy: string
{
    case STATIC = 'static';      // Vollständig statischer Content
    case PARTIAL = 'partial';    // Teilweise dynamischer Content
    case FRAGMENT = 'fragment';  // Fragment-basiertes Caching
    case DYNAMIC = 'dynamic';    // Kein Caching (vollständig dynamisch)

    public function getTtl(): int
    {
        return match($this) {
            self::STATIC => 3600,    // 1 Stunde
            self::PARTIAL => 900,    // 15 Minuten
            self::FRAGMENT => 600,   // 10 Minuten
            self::DYNAMIC => 0,      // Kein Caching
        };
    }

    public function getPriority(): int
    {
        return match($this) {
            self::STATIC => 1,       // Höchste Priorität
            self::PARTIAL => 2,
            self::FRAGMENT => 3,
            self::DYNAMIC => 4,      // Niedrigste Priorität
        };
    }

    public function shouldCache(): bool
    {
        return $this !== self::DYNAMIC;
    }

    public function getDescription(): string
    {
        return match($this) {
            self::STATIC => 'Fully cacheable static content',
            self::PARTIAL => 'Partially cacheable with some dynamic elements',
            self::FRAGMENT => 'Fragment-based caching for mixed content',
            self::DYNAMIC => 'Fully dynamic content, no caching',
        };
    }
}
