This commit is contained in:
eric
2026-03-26 11:41:00 -05:00
parent 11ea8d402c
commit a8976b2eee

View File

@@ -16,27 +16,22 @@ type PayjsVipResult = {
}; };
const inflightUserChecks = new Map<string, Promise<PayjsVipResult | null>>(); const inflightUserChecks = new Map<string, Promise<PayjsVipResult | null>>();
type UserCheckPayload = {
ok: boolean;
vip: boolean;
alreadyLinked: boolean;
email?: string;
linkedUserId?: string;
};
const inflightUserRequests = new Map< const inflightUserRequests = new Map<
string, string,
Promise<{ Promise<UserCheckPayload>
ok: true;
vip: boolean;
alreadyLinked: boolean;
email?: string;
linkedUserId?: string;
}>
>(); >();
const userCheckResultCache = new Map< const userCheckResultCache = new Map<
string, string,
{ {
expiresAt: number; expiresAt: number;
payload: { payload: UserCheckPayload;
ok: true;
vip: boolean;
alreadyLinked: boolean;
email?: string;
linkedUserId?: string;
};
} }
>(); >();
const USER_CHECK_CACHE_TTL_MS = Number(process.env.CHECK_BY_USER_CACHE_TTL_MS) || 10_000; const USER_CHECK_CACHE_TTL_MS = Number(process.env.CHECK_BY_USER_CACHE_TTL_MS) || 10_000;