shinroute / src /app /api /cache /route.ts
shinmentakezo07
Add OmniRoute codebase without binary assets
9e4583c
Raw
History Blame Contribute Delete
900 Bytes
import { NextResponse } from "next/server";
import { getCacheStats, clearCache, cleanExpiredEntries } from "@/lib/semanticCache";
import { getIdempotencyStats } from "@/lib/idempotencyLayer";
/**
* GET /api/cache — Cache statistics
*/
export async function GET() {
try {
const cacheStats = getCacheStats();
const idempotencyStats = getIdempotencyStats();
return NextResponse.json({
semanticCache: cacheStats,
idempotency: idempotencyStats,
});
} catch (error) {
return NextResponse.json({ error: error.message }, { status: 500 });
}
}
/**
* DELETE /api/cache — Clear all caches
*/
export async function DELETE() {
try {
clearCache();
const cleaned = cleanExpiredEntries();
return NextResponse.json({ ok: true, expiredRemoved: cleaned });
} catch (error) {
return NextResponse.json({ error: error.message }, { status: 500 });
}
}