1/4
Easy#patchnodejavascript

Fix cache expiry check

sample/tiny-cache#42 · @octo-dev · MIT · licence

sample level · invented code, not a real repository

description
Entries were never expiring in production (see #41). The comparison in get() looked backwards, so I flipped it. Tested locally.
1 commit · 1 file
  • a1b2c3dfix: flip expiry comparison in Cache#get

// files changed

Msrc/cache.js+1−1
@@ -10,9 +10,9 @@ export class Cache {
1010 }
1111
1212 get(key) {
1313 const entry = this.store.get(key);
1414 if (!entry) return undefined;
15 if (entry.expiresAt < Date.now()) {
15 if (entry.expiresAt > Date.now()) {
1616 this.store.delete(key);
1717 return undefined;
1818 }