Files
michaelschiemer/tests/debug/test-cache-hit.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

60 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\Cache\CacheInitializer;
use App\Framework\Core\PathProvider;
use App\Framework\DateTime\SystemClock;
use App\Framework\DateTime\SystemHighResolutionClock;
use App\Framework\DI\DefaultContainer;
use App\Framework\Discovery\Cache\DiscoveryCacheIdentifiers;
use App\Framework\Performance\EnhancedPerformanceCollector;
use App\Framework\Performance\MemoryMonitor;
echo "=== Testing Cache Hit Detection ===\n\n";
$basePath = dirname(__DIR__, 2);
$pathProvider = new PathProvider($basePath);
$clock = new SystemClock();
// Create cache
$highResClock = new SystemHighResolutionClock();
$memoryMonitor = new MemoryMonitor();
$performanceCollector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, false);
$container = new DefaultContainer();
$cacheInitializer = new CacheInitializer($performanceCollector, $container);
$cache = $cacheInitializer();
// Generate the exact cache key using the new CacheIdentifier system
$defaultPaths = [$pathProvider->getSourcePath()];
$cacheKey = DiscoveryCacheIdentifiers::fullDiscoveryKey($defaultPaths);
echo "Checking cache key: {$cacheKey->toString()}\n";
echo "Source path: {$pathProvider->getSourcePath()}\n";
// Check cache
$cachedItem = $cache->get($cacheKey);
if ($cachedItem !== null) {
echo "✅ CACHE HIT! Registry found in cache.\n";
if ($cachedItem->value !== null) {
echo "Registry type: " . get_class($cachedItem->value) . "\n";
} else {
echo "⚠️ Registry value is null - deserialization issue?\n";
}
if ($cachedItem->value instanceof \App\Framework\Discovery\Results\DiscoveryRegistry) {
$registry = $cachedItem->value;
echo "Routes count: " . $registry->routes->count() . "\n";
echo "Attributes count: " . count($registry->attributes->getAllTypes()) . "\n";
echo "Interfaces count: " . $registry->interfaces->count() . "\n";
echo "Templates count: " . $registry->templates->count() . "\n";
}
} else {
echo "❌ CACHE MISS! No registry found in cache.\n";
}
echo "\nDone.\n";