Remove Realtime Database metrics for game list cache.

경기 일정 캐시의 적중률(Hit/Miss)을 RTDB에 기록하던 로직을 제거
This commit is contained in:
윤정민 2026-04-14 22:17:51 +09:00
parent 6145af7159
commit 98502916de

View File

@ -1,5 +1,3 @@
import { ServerValue } from "firebase-admin/database";
import { rtdb } from "../firebase.js";
import {
fetchGameList,
LEAGUE_CODES,
@ -27,25 +25,6 @@ function memGet(key: string): GameListResult | null {
return e.data;
}
function todayYmd(): string {
const n = new Date();
return `${n.getFullYear()}${String(n.getMonth() + 1).padStart(2, "0")}${String(n.getDate()).padStart(2, "0")}`;
}
/**
* hit/miss RTDB에 .
*
* : `/metrics/gameListCache/{YYYYMMDD}/{hit|miss}` .
* await fire-and-forget으로 ,
* ( ).
*/
function recordCacheMetric(kind: "hit" | "miss"): void {
rtdb
.ref(`metrics/gameListCache/${todayYmd()}/${kind}`)
.set(ServerValue.increment(1))
.catch(() => undefined);
}
function memSet(key: string, data: GameListResult): void {
if (memCache.size >= MEM_MAX) {
const oldest = memCache.keys().next().value;
@ -70,11 +49,7 @@ export async function getGameList(
const key = `${dateStr}|${resolvedSeries ?? ""}|${resolvedLeague ?? ""}`;
const hit = memGet(key);
if (hit) {
recordCacheMetric("hit");
return hit;
}
recordCacheMetric("miss");
if (hit) return hit;
const result = await fetchGameList({
date,