add better cache for getProfileId

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-08-08 22:02:13 +02:00
committed by Carl-Gerhard Lindesvärd
parent 7d703bcd80
commit b02cbb2946
3 changed files with 44 additions and 6 deletions

View File

@@ -180,6 +180,7 @@ export async function createProfileAlias({
alias: string;
profileId: string;
}) {
await getProfileIdCached.clear({ profileId, projectId });
await ch.insert({
table: TABLE_NAMES.alias,
format: 'JSONEachRow',
@@ -221,7 +222,7 @@ export async function getProfileId({
profileId,
projectId,
}: {
profileId: string | undefined;
profileId: number | string | undefined;
projectId: string;
}) {
if (!profileId) {
@@ -240,7 +241,7 @@ export async function getProfileId({
return res[0].profile_id;
}
return profileId;
return String(profileId);
}
export const getProfileIdCached = cacheable(getProfileId, 60 * 30);