Files
michaelschiemer/.archive/Archived/CacheStrategy.php

42 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace Archive\Archived;
enum CacheStrategy: string
{
case STATIC = 'static';
case PARTIAL = 'partial';
case FRAGMENT = 'fragment';
case DYNAMIC = 'dynamic';
case DISABLED = 'disabled';
public function getTtl(): int
{
return match($this) {
self::STATIC => 3600, // 1 Stunde für statische Inhalte
self::PARTIAL => 900, // 15 Minuten für teilweise dynamische Inhalte
self::FRAGMENT => 300, // 5 Minuten für Fragment-Cache
self::DYNAMIC => 0, // Keine Caching für dynamische Inhalte
self::DISABLED => 0, // Caching deaktiviert
};
}
public function getPriority(): int
{
return match($this) {
self::STATIC => 1,
self::PARTIAL => 2,
self::FRAGMENT => 3,
self::DYNAMIC => 4,
self::DISABLED => 5,
};
}
public function shouldCache(): bool
{
return $this !== self::DYNAMIC && $this !== self::DISABLED;
}
}