From fbf8cc82defe560392e704be5134de2297fed6c5 Mon Sep 17 00:00:00 2001 From: saopig1 Date: Mon, 30 Mar 2026 20:20:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20cidCache=20=E5=A4=A7=E5=B0=8F=E9=99=90?= =?UTF-8?q?=E5=88=B6=E4=B8=BA500=E6=9D=A1=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- src/music/bilibili.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/music/bilibili.ts b/src/music/bilibili.ts index c713a54..d2bd64a 100644 --- a/src/music/bilibili.ts +++ b/src/music/bilibili.ts @@ -161,6 +161,12 @@ export class BiliBiliProvider implements MusicProvider { const cached = this.cidCache.get(bvid); if (cached) return cached; + // Limit cache size to prevent unbounded growth + if (this.cidCache.size > 500) { + const firstKey = this.cidCache.keys().next().value; + if (firstKey) this.cidCache.delete(firstKey); + } + const detail = await this.getSongDetail(bvid); if (!detail) return null; return this.cidCache.get(bvid) ?? null;