BuidlZone-Labs/zicket-web

Unbounded In-Memory Cache Class Lacks Eviction & Serverless Persistence

开放

#177 创建于 2026年7月29日

 (13 条评论) (0 个反应) (1 位负责人)TypeScript (43 个派生)auto 404
Stellar Wavedifficulty: mediumenhancementhelp wantedperformance

仓库指标

星标
 (4 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Category

Performance

Priority

Medium

Description

lib/cache.ts provides InMemoryCache using a static JS Map. In long-running node processes, key entries accumulate indefinitely without an LRU maximum capacity cap. In serverless deployment environments (Vercel Edge/Lambdas), static Map state is lost between cold starts and isolated per instance.

Evidence from lib/cache.ts#L18-L20:

class InMemoryCache {
  private static store = new Map<string, CacheEntry<unknown>>();
}

Proposed Solution

  1. Add an upper bound on key size and implement LRU (Least Recently Used) cache eviction.
  2. For production deployments, integrate Redis / Upstash or Next.js unstable_cache / fetch cache.

Acceptance Criteria

  • Cache map respects a configurable max capacity (e.g. 500 items).
  • Expired or old items are evicted automatically.
  • No unbounded memory growth.

Files

  • lib/cache.ts
  • lib/dataFetching.ts

贡献者指南