diff --git a/wattpad.ts b/wattpad.ts index 511deab..d02ca33 100644 --- a/wattpad.ts +++ b/wattpad.ts @@ -17,23 +17,14 @@ const cache: { }; } = {}; -// re-init oldest story in cache every 5 minutes +// delete oldest story in cache every 5 minutes as to not memory leak to hell and back setInterval(() => { const oldStory = Object.values(cache).sort((a, b) => // @ts-expect-error 2363; javascript is a disgrace but it makes sorting dates easy so ¯\_(ツ)_/¯ b.timestamp - a.timestamp ).pop(); // teehee if (!oldStory) return; - cache[oldStory.story.id].timestamp = new Date(); - cache[oldStory.story.id].story.init().then(async (_) => { - for ( - let i = 0; - i < cache[oldStory.story.id].story.chapters.length; - i++ - ) { - await cache[oldStory.story.id].story.chapters[i].init(); - } - }); + delete cache[oldStory.story.id]; }, 300000); export { watt };