Files
sendou.ink/app/features/api-private/core/refresh-caches.server.ts
Kalle 7dca9ec51a Reduce server load from revalidation broadcast storms
Throttle revalidation broadcasts per room to at most a leading and a
trailing one per 2s window, jitter clients' refetch so a fan-out does not
hit all at once, stop broadcasting to the looking room on every ready
check confirmation, and serve the looking page's user cards from a
short-lived cache.
2026-08-08 14:01:24 +03:00

31 lines
1.3 KiB
TypeScript

import { refreshApiTokensCache } from "~/features/api-public/api-public-utils.server";
import { refreshBannedCache } from "~/features/ban/core/banned.server";
import { clearParticipationInfoMap } from "~/features/front-page/core/ShowcaseTournaments.server";
import { refreshSendouQInstance } from "~/features/sendouq/core/SendouQ.server";
import { clearSeasonSkillsCache } from "~/features/sendouq/q-utils.server";
import {
clearAllTournamentDataCache,
refreshRunningTournaments,
} from "~/features/tournament-bracket/core/Tournament.server";
import { refreshTentativeTiersCache } from "~/features/tournament-organization/core/tentativeTiers.server";
import { clearUserCardCache } from "~/features/user-card/UserCardRepository.server";
import { cache } from "~/utils/cache.server";
/**
* Clears and refreshes every in-process cache, so the server serves what is in
* the database right now. E2E workers call this (via the route) after writing
* test data straight into the database file.
*/
export async function refreshCaches() {
clearAllTournamentDataCache();
clearParticipationInfoMap();
clearSeasonSkillsCache();
clearUserCardCache();
cache.clear();
await refreshBannedCache();
await refreshSendouQInstance();
await refreshTentativeTiersCache();
await refreshApiTokensCache();
await refreshRunningTournaments();
}