Skip to content

Commit 277bb8a

Browse files
committed
Refactor cache expiration logic in cache.ts by renaming duration variable to expiryInSeconds for improved clarity and maintainability.
1 parent 4f8e1a6 commit 277bb8a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/cache.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { join } from "path";
1313
// to be this simple and this is easy to write.
1414
//
1515

16-
const duration = 1000 * 60 * 60 * 24;
16+
const expiryInSeconds = 1000 * 60 * 60 * 24;
1717

1818
const basedir = join(process.cwd(), ".cache");
1919
mkdirSync(basedir, { recursive: true });
@@ -44,7 +44,10 @@ const get = (key: string): any => {
4444
const set = (key: string, data: any): void => {
4545
console.log("cache: write %s", key);
4646
const path = join(basedir, keyToFilename(key));
47-
const obj = JSON.stringify({ expiration: Date.now() + duration, data });
47+
const obj = JSON.stringify({
48+
expiration: Date.now() + expiryInSeconds,
49+
data,
50+
});
4851
writeFileSync(path, obj, "utf8");
4952
};
5053

0 commit comments

Comments
 (0)