diff options
author | mat <github@matdoes.dev> | 2021-06-01 17:17:12 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-06-01 17:17:12 -0500 |
commit | 58cf3377dfcb47d58e2ef936dcbbfa99c37783c4 (patch) | |
tree | b51bc425acbdf7e716ba351919bc2bfcb629075b /build/database.js | |
parent | aeb5f0d176d11a3b15d98e136ad9e420fd6cb416 (diff) | |
download | skyblock-api-58cf3377dfcb47d58e2ef936dcbbfa99c37783c4.tar.gz skyblock-api-58cf3377dfcb47d58e2ef936dcbbfa99c37783c4.tar.bz2 skyblock-api-58cf3377dfcb47d58e2ef936dcbbfa99c37783c4.zip |
make new "cache" for recentlyqueued
Diffstat (limited to 'build/database.js')
-rw-r--r-- | build/database.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/build/database.js b/build/database.js index 381be7c..e0c8924 100644 --- a/build/database.js +++ b/build/database.js @@ -42,6 +42,12 @@ const recentlyUpdated = new node_cache_1.default({ checkperiod: 60, useClones: false, }); +// don't add stuff to the queue within the same 5 minutes +const recentlyQueued = new node_cache_1.default({ + stdTTL: 60 * 5, + checkperiod: 60, + useClones: false, +}); exports.cachedRawLeaderboards = new Map(); const leaderboardMax = 100; const reversedLeaderboards = [ @@ -512,15 +518,19 @@ exports.leaderboardUpdateProfileQueue = new queue_promise_1.default({ }); /** Queue an update for the member's leaderboard data on the server if applicable */ function queueUpdateDatabaseMember(member, profile) { - if (recentlyUpdated.get(profile.uuid + member.uuid)) + if (recentlyQueued.get(profile.uuid + member.uuid)) return; + else + recentlyQueued.set(profile.uuid + member.uuid, true); exports.leaderboardUpdateMemberQueue.enqueue(async () => await updateDatabaseMember(member, profile)); } exports.queueUpdateDatabaseMember = queueUpdateDatabaseMember; /** Queue an update for the profile's leaderboard data on the server if applicable */ function queueUpdateDatabaseProfile(profile) { - if (recentlyUpdated.get(profile.uuid + 'profile')) + if (recentlyQueued.get(profile.uuid + 'profile')) return; + else + recentlyQueued.set(profile.uuid + 'profile', true); exports.leaderboardUpdateProfileQueue.enqueue(async () => await updateDatabaseProfile(profile)); } exports.queueUpdateDatabaseProfile = queueUpdateDatabaseProfile; |