Skip to content

Conversation

Copy link

Copilot AI commented Jan 5, 2026

The mset method bypassed maxKeys restrictions, allowing unlimited key insertion. Additionally, both set and mset incorrectly incremented counts when overwriting existing keys, causing count drift from actual stored keys.

Changes:

  • maxKeys enforcement in mset: Check limit before each new key insertion, stop processing when reached
  • Count tracking fix: Only increment count for new keys, not overwrites. Check key existence before setting to distinguish new vs existing keys
  • Performance optimization: Batch existence checks in mset using mget only when maxKeys enabled
  • Documentation: Added JSDoc clarifying partial success behavior when limit is reached

Example:

const store = new NodeCacheStore({ maxKeys: 2 });
await store.set("key1", "value1");
await store.set("key2", "value2");

// Previously: Would succeed, bypassing limit
// Now: Stops at limit
await store.mset([
  { key: "key1", value: "updated" },  // ✓ Overwrite succeeds
  { key: "key3", value: "new" },       // ✗ Rejected, limit reached
  { key: "key4", value: "new" },       // ✗ Not processed
]);

Note: The mget implementation still uses sequential get operations rather than true batch retrieval - improving this would require changes to the underlying Keyv store interface.


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

Copilot AI and others added 5 commits January 5, 2026 22:18
Co-authored-by: jaredwray <1205481+jaredwray@users.noreply.github.com>
Co-authored-by: jaredwray <1205481+jaredwray@users.noreply.github.com>
Co-authored-by: jaredwray <1205481+jaredwray@users.noreply.github.com>
Co-authored-by: jaredwray <1205481+jaredwray@users.noreply.github.com>
Co-authored-by: jaredwray <1205481+jaredwray@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 changed the title [WIP] Update to address feedback on Keyv migration Enforce maxKeys limit in mset and fix count tracking for overwrites Jan 5, 2026
Copilot AI requested a review from jaredwray January 5, 2026 22:28
@jaredwray jaredwray closed this Jan 6, 2026
@jaredwray jaredwray deleted the copilot/sub-pr-1524-another-one 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