Skip to content

Commit

Permalink
fix: this.expiration should be in ms when added to Date.now()
Browse files Browse the repository at this point in the history
  • Loading branch information
gamemaker1 committed Sep 16, 2023
1 parent 2779938 commit 4cbe6a2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/memcached-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class MemcachedStore implements Store {
totalHits = 1 // When you set it to 1, it returns `true` for some reason.

// Also store the expiration time in a separate key.
expiresAt = Date.now() + this.expiration
expiresAt = Date.now() + this.expiration * 1000 // [seconds -> milliseconds]
await this.fns.set(
this.expiryKey(key), // The name of the key.
expiresAt, // The value - the time at which the key expires.
Expand All @@ -163,7 +163,9 @@ class MemcachedStore implements Store {
// Return the total number of hits, as well as the reset timestamp.
return {
totalHits,
resetTime: expiresAt === undefined ? undefined : new Date(expiresAt),
// If `expiresAt` is undefined, assume the key expired sometime in between
// reading the hits and expiry keys from memcached.
resetTime: expiresAt ? new Date(expiresAt) : new Date(),
}
}

Expand Down

0 comments on commit 4cbe6a2

Please sign in to comment.