diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-01 14:22:01 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-01 14:22:01 -0600 |
commit | 8dff3de251892eed1bc25223e789a61d9fa98699 (patch) | |
tree | fece4a01822efb76d67e703dbce8d50d774527b0 /build/hypixelCached.js | |
parent | b82e1d986cdb20952e26dd6153a0749b87c56b38 (diff) | |
download | skyblock-api-8dff3de251892eed1bc25223e789a61d9fa98699.tar.gz skyblock-api-8dff3de251892eed1bc25223e789a61d9fa98699.tar.bz2 skyblock-api-8dff3de251892eed1bc25223e789a61d9fa98699.zip |
tsc
Diffstat (limited to 'build/hypixelCached.js')
-rw-r--r-- | build/hypixelCached.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/build/hypixelCached.js b/build/hypixelCached.js index c4a3743..48b8ff0 100644 --- a/build/hypixelCached.js +++ b/build/hypixelCached.js @@ -40,12 +40,12 @@ const usernameCache = new node_cache_1.default({ const basicProfilesCache = new node_cache_1.default({ stdTTL: 60 * 10, checkperiod: 60, - useClones: false, + useClones: true, }); const playerCache = new node_cache_1.default({ stdTTL: 60, checkperiod: 10, - useClones: false, + useClones: true, }); const profileCache = new node_cache_1.default({ stdTTL: 30, @@ -78,6 +78,9 @@ function waitForSet(cache, key, value) { * @param user A user can be either a uuid or a username */ async function uuidFromUser(user) { + // if the user is 32 characters long, it has to be a uuid + if (util_1.undashUuid(user).length === 32) + return util_1.undashUuid(user); if (usernameCache.has(util_1.undashUuid(user))) { // check if the uuid is a key const username = usernameCache.get(util_1.undashUuid(user)); @@ -140,9 +143,8 @@ async function fetchPlayer(user) { if (!cleanPlayer) return; // clone in case it gets modified somehow later - const cleanPlayerClone = Object.assign({}, cleanPlayer); - playerCache.set(playerUuid, cleanPlayerClone); - usernameCache.set(playerUuid, cleanPlayerClone.username); + playerCache.set(playerUuid, cleanPlayer); + usernameCache.set(playerUuid, cleanPlayer.username); return cleanPlayer; } exports.fetchPlayer = fetchPlayer; |