<?php
require_once __DIR__ . '/../../vendor/autoload.php';
$app = require __DIR__ . '/../../app/bootstrap.php';

$cache = $app->services->kpiCache ?? null;
if (!$cache || !method_exists($cache, 'gc')) {
    echo "KPI cache service not available\n";
    exit(1);
}

$result = $cache->gc(true);
echo json_encode([
    'ok' => true,
    'gc' => $result,
    'at' => date('Y-m-d H:i:s')
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) . PHP_EOL;

