diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-01 22:00:53 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-01 22:00:53 -0600 |
commit | 2c2a465efb2535f2d9ce8d5865c276e2e91c4979 (patch) | |
tree | b2d9dafa3337be7aabb0929fc3cd5d96b8b5aee7 /src | |
parent | 49f0f038434d1b95f4218b97c7a41be8f869a4f7 (diff) | |
download | skyblock-api-2c2a465efb2535f2d9ce8d5865c276e2e91c4979.tar.gz skyblock-api-2c2a465efb2535f2d9ce8d5865c276e2e91c4979.tar.bz2 skyblock-api-2c2a465efb2535f2d9ce8d5865c276e2e91c4979.zip |
change concurrent updating leaderboard members to 1
Diffstat (limited to 'src')
-rw-r--r-- | src/database.ts | 2 | ||||
-rw-r--r-- | src/hypixelCached.ts | 8 |
2 files changed, 5 insertions, 5 deletions
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<any> { +function waitForCacheSet(cache: NodeCache, key?: string, value?: string): Promise<any> { 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<string> { 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<string> { 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) |