fix(node-cache): Fixing issues with metrics reporting#1650
Conversation
There was a problem hiding this comment.
Code Review
This pull request optimizes the node-cache package by introducing an in-memory _values map in NodeCacheStore to track cached values synchronously, preventing redundant asynchronous lookups and fixing stats inflation during key overwrites. It also updates the take() method to support falsy values and adds comprehensive tests. The reviewer feedback highlights two critical issues: first, using this.store.has() in take() can incorrectly identify expired keys as existing, leading to premature deletion when deleteOnExpire is disabled; second, checking result !== undefined in the store's retrieval logic fails when a cached value is explicitly set to undefined, which can cause memory leaks. Code suggestions are provided to address both issues.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
This MR fixes multiple metrics-accounting issues that caused inaccurate ksize and vsize reporting over time.
The changes ensure that: