From 631e6fe3717b0364da88c2f8ab0b23da7a4559e2 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 16:10:52 -0500 Subject: Fix high memory usage in basicPlayerCache hopefully --- src/hypixelCached.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/hypixelCached.ts') 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 = new LRUCache({ - max: 1000, + max: 10000, ttl: 60 * 20 * 1000, }) @@ -199,7 +199,14 @@ export async function fetchPlayer(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 -- cgit