From 2c2a465efb2535f2d9ce8d5865c276e2e91c4979 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Mon, 1 Mar 2021 22:00:53 -0600 Subject: change concurrent updating leaderboard members to 1 --- src/database.ts | 2 +- src/hypixelCached.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/database.ts b/src/database.ts index 09288e5..5d97e88 100644 --- a/src/database.ts +++ b/src/database.ts @@ -274,7 +274,7 @@ export async function updateDatabaseMember(member: CleanMember, profile: CleanFu } const queue = new Queue({ - concurrent: 10, + concurrent: 1, interval: 500 }) diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts index f76c52a..483b3fa 100644 --- a/src/hypixelCached.ts +++ b/src/hypixelCached.ts @@ -54,7 +54,7 @@ const profileNameCache = new NodeCache({ useClones: false, }) -function waitForSet(cache: NodeCache, key?: string, value?: string): Promise { +function waitForCacheSet(cache: NodeCache, key?: string, value?: string): Promise { return new Promise((resolve, reject) => { const listener = (setKey, setValue) => { if (setKey === key || (value && setValue === value)) { @@ -78,7 +78,7 @@ export async function uuidFromUser(user: string): Promise { if (usernameCache.has(undashUuid(user))) { // check if the uuid is a key const username: any = usernameCache.get(undashUuid(user)) - // if it has .then, then that means its a waitForSet promise. This is done to prevent requests made while it is already requesting + // if it has .then, then that means its a waitForCacheSet promise. This is done to prevent requests made while it is already requesting if (username.then) { const { key: uuid, value: _username } = await username usernameCache.set(uuid, _username) @@ -96,8 +96,8 @@ export async function uuidFromUser(user: string): Promise { if (debug) console.log('Cache miss: uuidFromUser', user) - // set it as waitForSet (a promise) in case uuidFromUser gets called while its fetching mojang - usernameCache.set(undashUuid(user), waitForSet(usernameCache, user, user)) + // set it as waitForCacheSet (a promise) in case uuidFromUser gets called while its fetching mojang + usernameCache.set(undashUuid(user), waitForCacheSet(usernameCache, user, user)) // not cached, actually fetch mojang api now let { uuid, username } = await mojang.mojangDataFromUser(user) -- cgit