Skip to content

Commit 0900dc4

Browse files
authored
fix: add missing cache ttl (#435)
1 parent 6dcc99c commit 0900dc4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

web/src/workers/language/language.worker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type * as monaco from 'monaco-editor'
22
import * as Comlink from 'comlink'
3+
import { addDays } from 'date-fns'
34
import { db, keyValue } from '~/services/storage'
45
import type { GoIndexFile, HoverQuery, LiteralQuery, PackageSymbolQuery, SuggestionQuery } from './types'
56
import {
@@ -15,6 +16,10 @@ import type { SymbolIndexItem } from '~/services/storage/types'
1516

1617
const completionVersionKey = 'completionItems.version'
1718

19+
const TTL_DAYS = 7
20+
21+
const getExpireTime = () => addDays(new Date(), TTL_DAYS)
22+
1823
const isPackageQuery = (q: SuggestionQuery): q is PackageSymbolQuery => 'packageName' in q
1924

2025
export class WorkerHandler {
@@ -190,7 +195,7 @@ export class WorkerHandler {
190195
this.db.symbolIndex.clear(),
191196
this.db.packageIndex.bulkAdd(packages),
192197
this.db.symbolIndex.bulkAdd(symbols),
193-
this.keyValue.setItem(completionVersionKey, data.go),
198+
this.keyValue.setItem(completionVersionKey, data.go, getExpireTime()),
194199
])
195200

196201
this.cachePopulated = true

0 commit comments

Comments
 (0)