Skip to content

fix(cache): enforce sqlite maxCount after insert#5112

Merged
mcollina merged 2 commits intonodejs:mainfrom
trivikr:sqlite-cache-store-max-count
Apr 27, 2026
Merged

fix(cache): enforce sqlite maxCount after insert#5112
mcollina merged 2 commits intonodejs:mainfrom
trivikr:sqlite-cache-store-max-count

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented Apr 25, 2026

This relates to...

Fixes: #5111

Rationale

SqliteCacheStore#set() pruned before inserting a new row, and #prune() returned early when size <= maxCount. That meant a store already at capacity accepted one more entry and only pruned on a later write. This change makes maxCount enforcement happen after insert so the store does not remain oversized.

Changes

Move SQLite cache pruning to run after inserting a new entry.

Features

N/A

Bug Fixes

Fix SqliteCacheStore allowing one extra cached row beyond maxCount.

Breaking Changes and Deprecations

N/A

Status

Assisted-by: openai:gpt-5.4

Assisted-by: openai:gpt-5.4
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.14%. Comparing base (9a6e313) to head (381d159).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5112   +/-   ##
=======================================
  Coverage   93.14%   93.14%           
=======================================
  Files         110      110           
  Lines       36117    36117           
=======================================
  Hits        33642    33642           
  Misses       2475     2475           

☔ 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.

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 2eb9ddc into nodejs:main Apr 27, 2026
35 checks passed
@trivikr trivikr deleted the sqlite-cache-store-max-count branch April 27, 2026 14:15
mcollina pushed a commit that referenced this pull request Apr 29, 2026
@github-actions github-actions Bot mentioned this pull request May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SqliteCacheStore allows maxCount to overshoot by one entry

3 participants