fix(core): PHPMNT-394 Normalise maxSize so invalid values cannot disable memoization - #68
Draft
TomA-R wants to merge 1 commit into
Draft
fix(core): PHPMNT-394 Normalise maxSize so invalid values cannot disable memoization#68TomA-R wants to merge 1 commit into
TomA-R wants to merge 1 commit into
Conversation
…ble memoization Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
TomA-R
force-pushed
the
phpmnt-394-normalise-max-size
branch
from
August 13, 2026 07:32
5b74725 to
467795b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: PHPMNT-394
What/Why?
A fractional or negative
maxSizesilently turns memoization off entirely:With
maxSize: 0.5, the LRU set (size 1 after the first call) always "exceeds" the limit, so the key that was just issued is immediately expired — every call recomputes and the consumer gets no signal that anything is wrong. Negative and NaN values behave the same way, andInfinityhas the opposite problem: every key is tracked for expiry but none ever expires, so the tracking set grows forever. ThemaxSizetype isnumber, so a computed value can hit any of these without a type error.Fix: the resolver now floors fractions and treats anything below 1 or non-finite as "no limit" (
Number.isFinite(maxSize) ? Math.max(0, Math.floor(maxSize)) : 0). So2.7behaves as2, while0.5,-1,NaN, andInfinitybehave as the default unlimited cache — degraded gracefully instead of silently misbehaving.Rollout/Rollback
Merge / revert
Testing
Tests added at the resolver level (below-one values, non-finite values, fractional flooring) and the memoize level.