chore: complete update
This commit is contained in:
30
.archive/Optimized/CacheAnalysis.php
Normal file
30
.archive/Optimized/CacheAnalysis.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Archive\Optimized;
|
||||
|
||||
/**
|
||||
* Cache-Analyse für Template-Rendering
|
||||
*/
|
||||
final readonly class CacheAnalysis
|
||||
{
|
||||
public function __construct(
|
||||
public CacheStrategy $strategy,
|
||||
public int $ttl,
|
||||
public array $dependencies = [],
|
||||
) {}
|
||||
|
||||
public function shouldCache(): bool
|
||||
{
|
||||
return $this->strategy !== CacheStrategy::DYNAMIC && $this->ttl > 0;
|
||||
}
|
||||
|
||||
public function isUserSpecific(): bool
|
||||
{
|
||||
return isset($this->dependencies['user_id']) || isset($this->dependencies['session_id']);
|
||||
}
|
||||
|
||||
public function getComplexity(): int
|
||||
{
|
||||
return count($this->dependencies) + ($this->isUserSpecific() ? 5 : 0);
|
||||
}
|
||||
}
|
||||
49
.archive/Optimized/CacheStrategy.php
Normal file
49
.archive/Optimized/CacheStrategy.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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',
|
||||
};
|
||||
}
|
||||
}
|
||||
30
.archive/Optimized/TemplateAnalysis.php
Normal file
30
.archive/Optimized/TemplateAnalysis.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Archive\Optimized;
|
||||
|
||||
/**
|
||||
* Template-Analyse-Ergebnisse
|
||||
*/
|
||||
final class TemplateAnalysis
|
||||
{
|
||||
public array $staticBlocks = [];
|
||||
public array $dynamicBlocks = [];
|
||||
public array $dependencies = [];
|
||||
public array $optimizations = [];
|
||||
public CacheStrategy $cacheStrategy = CacheStrategy::DYNAMIC;
|
||||
|
||||
public function getComplexity(): int
|
||||
{
|
||||
return count($this->staticBlocks) + count($this->dynamicBlocks) * 2;
|
||||
}
|
||||
|
||||
public function isCacheable(): bool
|
||||
{
|
||||
return $this->cacheStrategy !== CacheStrategy::DYNAMIC;
|
||||
}
|
||||
|
||||
public function hasFragments(): bool
|
||||
{
|
||||
return count($this->staticBlocks) > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user