Skip to content

fix: 🐛 improve LruTtlMap - #106

Merged
streamich merged 1 commit into
mainfrom
lru-ttl-fix
Jul 26, 2026
Merged

fix: 🐛 improve LruTtlMap#106
streamich merged 1 commit into
mainfrom
lru-ttl-fix

Conversation

@streamich

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 26, 2026 11:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves LruTtlMap’s TTL semantics and internal bookkeeping so that expiry metadata stays consistent with the underlying LRU map, and so callers get sensible default “current time” behavior.

Changes:

  • Add clearer API documentation for LruTtlMap, including explicit semantics for now and absolute expiry deadlines.
  • Change LruTtlMap.has() to default now to Date.now() so expired entries are treated as missing even when callers omit now.
  • Fix LRU-eviction cleanup by having LruMap.set() evict via this.delete(...), allowing subclasses (like LruTtlMap) to keep side-maps in sync, and add tests covering expiry side-map non-leak scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/LruTtlMap.ts Documents TTL behavior and updates default now handling; ensures expiry bookkeeping remains aligned with reads/writes.
src/LruMap.ts Ensures evictions go through polymorphic delete() so subclasses can perform cleanup (e.g., removing expiry metadata).
src/tests/LruTtlMap.spec.ts Adds regression tests to ensure expiry side-map does not leak on eviction/overwrite/clear/delete and validates default-now expiry behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@streamich
streamich merged commit 96ee879 into main Jul 26, 2026
2 checks passed
@streamich
streamich deleted the lru-ttl-fix branch July 26, 2026 11:09
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants