31 lines
690 B
PHP
31 lines
690 B
PHP
<?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);
|
|
}
|
|
}
|