diff options
author | mat <github@matdoes.dev> | 2022-07-01 16:10:52 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-07-01 16:10:52 -0500 |
commit | 631e6fe3717b0364da88c2f8ab0b23da7a4559e2 (patch) | |
tree | ec5e8299735c5b3300f64c42768d6ac1bedf074e /src/hypixelCached.ts | |
parent | 9661f44e2eff4a3564d2a651bea1434d9cadf067 (diff) | |
download | skyblock-api-631e6fe3717b0364da88c2f8ab0b23da7a4559e2.tar.gz skyblock-api-631e6fe3717b0364da88c2f8ab0b23da7a4559e2.tar.bz2 skyblock-api-631e6fe3717b0364da88c2f8ab0b23da7a4559e2.zip |
Fix high memory usage in basicPlayerCache hopefully
Diffstat (limited to 'src/hypixelCached.ts')
-rw-r--r-- | src/hypixelCached.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts index 6f91e22..75cf1a7 100644 --- a/src/hypixelCached.ts +++ b/src/hypixelCached.ts @@ -40,7 +40,7 @@ export const playerCache = new NodeCache({ // cache "basic players" (players without profiles) for 20 minutes export const basicPlayerCache: LRUCache<string, CleanPlayer> = new LRUCache({ - max: 1000, + max: 10000, ttl: 60 * 20 * 1000, }) @@ -199,7 +199,14 @@ export async function fetchPlayer<Full extends boolean = true>(user: string, ful usernameCache.set(playerUuid, cleanPlayer.username) // clone in case it gets modified somehow later - const cleanBasicPlayer = Object.assign({}, cleanPlayer) + const clonedCleanPlayer = Object.assign({}, cleanPlayer) + const cleanBasicPlayer: CleanPlayer = { + rank: clonedCleanPlayer.rank, + socials: clonedCleanPlayer.socials, + username: clonedCleanPlayer.username, + uuid: clonedCleanPlayer.uuid, + profiles: clonedCleanPlayer.profiles + } if (cleanBasicPlayer.profiles) { // remove the names from the profiles so we only keep uuids // this helps save a bit of memory since we don't care about the names |