mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
fix: cidCache 大小限制为500条,防止内存泄漏
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5e4d318a2a
commit
fbf8cc82de
1 file changed
+6
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user