From: Chris Duncan Date: Wed, 18 Jun 2025 21:40:57 +0000 (-0700) Subject: Limit cache to 1000 items for performance. X-Git-Tag: v5.1.0~5^2~1 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=8a1a88a9a7e6e7a0a92cac64a12786cd708f4453;p=nano-pow.git Limit cache to 1000 items for performance. --- diff --git a/src/utils/cache.ts b/src/utils/cache.ts index 35ee12c..76d647e 100644 --- a/src/utils/cache.ts +++ b/src/utils/cache.ts @@ -32,7 +32,7 @@ export class Cache { static store (result: WorkGenerateResponse): WorkGenerateResponse { const item = this.#getItem('NanoPowCache') const cache = JSON.parse(item ?? '[]') as WorkGenerateResponse[] - cache.push(result) + if (cache.push(result) > 1000) cache.shift() this.#setItem('NanoPowCache', JSON.stringify(cache)) return result }