]> git.codecow.com Git - nano-pow.git/commitdiff
Limit cache to 1000 items for performance.
authorChris Duncan <chris@zoso.dev>
Wed, 18 Jun 2025 21:40:57 +0000 (14:40 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 18 Jun 2025 21:40:57 +0000 (14:40 -0700)
src/utils/cache.ts

index 35ee12cba5b10e214a0b61da4730eee7cfa51b41..76d647e33afcf7789fc9ca8d645f6fa0d3e310b5 100644 (file)
@@ -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
        }