Skip to content

Add ability to detect when MemoryCacheStore reaches max size#4224

Merged
mcollina merged 4 commits intonodejs:mainfrom
FelixVaughan:memorycachestore-max-size
May 20, 2025
Merged

Add ability to detect when MemoryCacheStore reaches max size#4224
mcollina merged 4 commits intonodejs:mainfrom
FelixVaughan:memorycachestore-max-size

Conversation

@FelixVaughan
Copy link
Copy Markdown
Contributor

@FelixVaughan FelixVaughan commented May 15, 2025

This relates to...

This is addressing #4185

Rationale

Currently it's possible to configure a maxSize with MemoryCacheStore, but there isn't a way to detect when this max size has been exceeded.

Changes

Added methods to get size of a memory cache, and check whether it is overflowing as well as an event which is emitted when the cache is full. Also added tests and updated docs.

Features

  1. Added size getter on MemoryCacheStore
  2. Added isFull public method on MemoryCacheStore
  3. Added maxSizeExceeded event on MemoryCacheStore

Bug Fixes

N/A

Breaking Changes and Deprecations

N/A

Status

@FelixVaughan FelixVaughan changed the title Initial impl Add ability to detect when MemoryCacheStore reaches max size May 15, 2025
Comment thread test/memory-cache-store-size.js Outdated
@@ -0,0 +1,123 @@
'use strict'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you please move this test together to the others of the cache?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I moved them to memory-cache-store-tests.js. Let me know if you had somewhere else in mind.

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 a8d280c into nodejs:main May 20, 2025
29 of 31 checks passed
@github-actions github-actions Bot mentioned this pull request May 20, 2025
slagiewka pushed a commit to slagiewka/undici that referenced this pull request Feb 14, 2026
…4224)

* Initial impl

* modified failing test

* modified a comment

* moved tests in memory-cache-store-size.js to memory-cache-store-tests.js
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.

2 participants