Skip to content

Conversation

Copy link

Copilot AI commented Jan 5, 2026

The setTtl method was checking item existence via get() but not tracking hits/misses, creating inconsistent stats compared to other cache operations.

Changes

  • Stats tracking in setTtl: Increments hits when item exists, misses when not found
  • Stats tracking in take: Same pattern applied for consistency across all retrieval operations
  • Public stats accessor: Added get stats() to enable verification of tracking behavior
  • Condition consistency: Changed if (item) to if (item !== undefined) to match get() method semantics

Example

const store = new NodeCacheStore();
await store.set("key", "value");

// Previously: no stats tracked
await store.setTtl("key", 1000);        // Now: increments hits
await store.setTtl("missing", 1000);    // Now: increments misses
await store.take("key");                // Now: increments hits

All methods that retrieve from cache now consistently track hits/misses.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 5, 2026 22:22
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] Update to address feedback on moving to Keyv as storage Track stats (hits/misses) in setTtl and take methods Jan 5, 2026
Copilot AI requested a review from jaredwray January 5, 2026 22:26
Base automatically changed from node-cache---feat-(breaking)-moving-to-Keyv-as-the-storage to main January 5, 2026 22:27
@jaredwray jaredwray closed this Jan 6, 2026
@jaredwray jaredwray deleted the copilot/sub-pr-1524-one-more-time 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