Skip to content

Conversation

Copy link

Copilot AI commented Jan 5, 2026

The set and mset methods unconditionally incremented the stats count, causing overcounting when updating existing keys instead of creating new ones.

Changes

  • set method: Check key existence via keyv.has() before incrementing count
  • mset method: Batch check keys via keyv.hasMany() and increment count only for new keys
  • take method: Fix incorrect method names (recordHit/recordMissincrementHits/incrementMisses)

Example

const store = new NodeCacheStore({ maxKeys: 10 });
await store.set("foo", "bar");  // count: 1
await store.set("foo", "baz");  // count: 1 (not 2)

await store.mset([
  { key: "a", value: "1" },
  { key: "b", value: "2" }
]);  // count: 3

await store.mset([
  { key: "a", value: "updated" },  // existing
  { key: "c", value: "3" }         // new
]);  // count: 4 (not 5)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

jaredwray and others added 9 commits January 5, 2026 10:13
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Base automatically changed from node-cache---feat-(breaking)-moving-to-Keyv-as-the-storage to main January 5, 2026 22:27
Copilot AI and others added 2 commits January 5, 2026 22:32
Co-authored-by: jaredwray <1205481+jaredwray@users.noreply.github.com>
Co-authored-by: jaredwray <1205481+jaredwray@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on moving to Keyv as storage Fix stats overcounting on key updates in set/mset methods Jan 5, 2026
Copilot AI requested a review from jaredwray January 5, 2026 22:37
@jaredwray jaredwray closed this Jan 6, 2026
@jaredwray jaredwray deleted the copilot/sub-pr-1524-ad6e7286-890e-4080-8f90-72a286fd5687 branch January 9, 2026 19:48
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