Skip to content

feat(cache/unstable): add sliding expiration to TtlCache#7046

Open
tomas-zijdemans wants to merge 3 commits intodenoland:mainfrom
tomas-zijdemans:ttl-cache-sliding
Open

feat(cache/unstable): add sliding expiration to TtlCache#7046
tomas-zijdemans wants to merge 3 commits intodenoland:mainfrom
tomas-zijdemans:ttl-cache-sliding

Conversation

@tomas-zijdemans
Copy link
Contributor

  • Sliding expiration: entries can now stay alive as long as they're being accessed, with an optional hard deadline. Useful for sessions or rate-limit windows.
  • Per-entry TTL overrides via an options object (replaces the old positional parameter).
  • Constructor and set() now validate inputs, rejecting bad values with clear errors.
  • onEject callback is now optional, and clear() calls it for every entry even if one throws.
  • delete() skips unnecessary work for non-existent keys.
  • Minor clearTimeout guard to avoid redundant calls.
  • Test coverage improved.

@tomas-zijdemans tomas-zijdemans requested a review from kt3k as a code owner March 13, 2026 11:56
@github-actions github-actions bot added the cache label Mar 13, 2026
@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 98.79518% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.02%. Comparing base (6df7f21) to head (e8757e8).

Files with missing lines Patch % Lines
cache/ttl_cache.ts 98.79% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7046   +/-   ##
=======================================
  Coverage   94.01%   94.02%           
=======================================
  Files         627      627           
  Lines       50029    50101   +72     
  Branches     8807     8830   +23     
=======================================
+ Hits        47037    47109   +72     
  Misses       2413     2413           
  Partials      579      579           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant