Skip to content

Commit

Permalink
use process.hrtime instead of Date.now (#1160)
Browse files Browse the repository at this point in the history
  • Loading branch information
hulkish authored and benmosher committed Sep 9, 2018
1 parent 6815513 commit 0764acd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/ModuleCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ModuleCache {
* @param {[type]} result [description]
*/
set(cacheKey, result) {
this.map.set(cacheKey, { result, lastSeen: Date.now() })
this.map.set(cacheKey, { result, lastSeen: process.hrtime() })
log('setting entry for', cacheKey)
return result
}
Expand All @@ -23,7 +23,7 @@ class ModuleCache {
if (this.map.has(cacheKey)) {
const f = this.map.get(cacheKey)
// check fresness
if (Date.now() - f.lastSeen < (settings.lifetime * 1000)) return f.result
if (process.hrtime(f.lastSeen)[0] < settings.lifetime) return f.result
} else log('cache miss for', cacheKey)
// cache miss
return undefined
Expand Down

0 comments on commit 0764acd

Please sign in to comment.