feat: add cache size retrieval functionality and display in CacheSettings component

This commit is contained in:
Julien Froidefond
2025-10-17 08:23:27 +02:00
parent 2c850d1c59
commit f636a7b112
7 changed files with 250 additions and 7 deletions

31
src/app/api/komga/cache/size/route.ts vendored Normal file
View File

@@ -0,0 +1,31 @@
import { NextResponse } from "next/server";
import type { ServerCacheService } from "@/lib/services/server-cache.service";
import { getServerCacheService } from "@/lib/services/server-cache.service";
import { ERROR_CODES } from "@/constants/errorCodes";
import { getErrorMessage } from "@/utils/errors";
export async function GET() {
try {
const cacheService: ServerCacheService = await getServerCacheService();
const { sizeInBytes, itemCount } = await cacheService.getCacheSize();
return NextResponse.json({
sizeInBytes,
itemCount,
mode: cacheService.getCacheMode()
});
} catch (error) {
console.error("Erreur lors de la récupération de la taille du cache:", error);
return NextResponse.json(
{
error: {
code: ERROR_CODES.CACHE.SIZE_FETCH_ERROR,
name: "Cache size fetch error",
message: getErrorMessage(ERROR_CODES.CACHE.SIZE_FETCH_ERROR),
},
},
{ status: 500 }
);
}
}