Repository navigation
feat(storage): bound memory storage with optional maxSize + LRU eviction - #38
Conversation
…Storage createMemoryStorage() was backed by an unbounded Map — entries were only removed by TTL expiry or explicit deletion, so high-cardinality or TTL-less keys could grow without limit and OOM. Add an optional maxSize (entry count) to createMemoryStorage(opts). When set, get() promotes hits to most-recently-used and set() evicts the least-recently-used entries once over the ceiling. Default stays unbounded so the zero-config path is unchanged. Closes #35 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Apply a sensible default bound (DEFAULT_MEMORY_MAX_SIZE = 1000) so the zero-config memory storage is safe out of the box. Pass maxSize to change the ceiling or Infinity to opt back into unbounded growth. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Per perf review, 1000 is low for a general/HTTP cache keyed per-URL and could thrash. Raise DEFAULT_MEMORY_MAX_SIZE to 10 000 — still bounds memory against unbounded high-cardinality growth while avoiding eviction churn for typical workloads. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Not part of the public API — drop it from index exports and the generated API docs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closes #35
Summary
createMemoryStorage()was backed by an unboundedMap— entries were only removed via TTL expiry or explicit deletion. High-cardinality keys (per-URL / per-user) and TTL-less entries could accumulate indefinitely, an unbounded memory leak that ends in OOM.This adds an opt-in size ceiling with LRU eviction while keeping the zero-config path unchanged.
Changes
createMemoryStorage(opts?)now accepts{ maxSize?: number }(entry count).get()promotes a hit to most-recently-used (reinsert;Mappreserves insertion order).set()reinserts at the most-recent position, then evicts the oldest entries (clearing their TTL timers) until back under the ceiling.maxSizeunset/0→ fully unbounded.MemoryStorageOptionstype.maxSizein the README Custom Storage section (automd API block regenerated).get/re-setrefreshing recency, unbounded-by-default.Notes
maxSizebounds entry count, not approximate byte size — simpler and predictable; byte-size accounting can be a follow-up.Verification
tsgo --noEmit: cleanobuild: succeeds🤖 Generated with Claude Code