Skip to content

Commit 9084e00

Browse files
committed
feat: update caching duration
1 parent f5199d8 commit 9084e00

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/main.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ let githubToken: string
1818

1919
const cachedGithubToken = await CACHE.get("github-token")
2020

21-
// If exists and at most 4 hours old
22-
if (cachedGithubToken) {
21+
const EIGHT_HOURS = 8 * 60 * 60 * 1000
22+
23+
// If exists and at most 8 hours old
24+
if (
25+
cachedGithubToken &&
26+
Date.now() - cachedGithubToken.createdAt < EIGHT_HOURS
27+
) {
2328
githubToken = cachedGithubToken.value
2429
} else {
2530
githubToken = await getGitHubToken()

0 commit comments

Comments
 (0)