Files
michaelschiemer/src/Framework/Database/Cache/ValueObjects/EntityMetrics.php
Michael Schiemer 55a330b223 Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
2025-08-11 20:13:26 +02:00

53 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Framework\Database\Cache\ValueObjects;
use App\Framework\Core\ValueObjects\Duration;
use App\Framework\Core\ValueObjects\Percentage;
/**
* Individual entity metrics value object
*/
final readonly class EntityMetrics
{
public function __construct(
public int $hits,
public int $misses,
public Percentage $hitRatio,
public int $cacheSize,
public Duration $averageAccessTime
) {
}
public function getTotalAccess(): int
{
return $this->hits + $this->misses;
}
public function isPopular(): bool
{
return $this->getTotalAccess() > 100; // Arbitrary threshold
}
public function isEfficient(): bool
{
return $this->hitRatio->isAbove(Percentage::from(60.0));
}
public function toArray(): array
{
return [
'hits' => $this->hits,
'misses' => $this->misses,
'hit_ratio' => $this->hitRatio->format(),
'cache_size' => $this->cacheSize,
'average_access_time_ms' => $this->averageAccessTime->toMilliseconds(),
'total_access' => $this->getTotalAccess(),
'is_popular' => $this->isPopular(),
'is_efficient' => $this->isEfficient(),
];
}
}