import { Router } from 'express';
import type { SemanticCache } from '../services/semantic-cache.js';
import { config } from '../config.js';
export function cacheRoutes(cache: SemanticCache): Router {
const router = Router();
router.get('/stats', (_req, res) => {
const size = cache.size;
const maxEntries = config.cache.maxEntries;
const ttlMs = config.cache.ttlMs;
const utilization = maxEntries > 0 ? Math.round((size / maxEntries) * 100) : 0;
res.json({ size, maxEntries, ttlMs, utilization });
});
router.post('/clear', (_req, res) => {
cache.clear();
res.json({ ok: true, message: 'Cache cleared' });
});
return router;
}