Skip to content

Commit d441b99

Browse files
committed
⚡ Reduce exit time when sync is enabled siyuan-note/siyuan#13604
1 parent 205805f commit d441b99

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

ref.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ func (repo *Repo) getFullLatest(latest *entity.Index) (ret *FullIndex) {
127127
return
128128
}
129129

130+
for _, f := range ret.Files {
131+
repo.store.cacheFile(f)
132+
}
133+
130134
logging.LogInfof("got local full latest [files=%d, size=%s], cost [%s]", len(ret.Files), humanize.Bytes(uint64(len(data))), time.Since(start))
131135
return
132136
}

store.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,7 @@ var indexCache, _ = ristretto.NewCache[string, any](&ristretto.Config[string, an
483483
MaxCost: 1000 * 1000 * 128, // 1 个文件按 300K 字节(大约 1.5W 个文件)计算,128MB 大概可以缓存 400 个索引
484484
BufferItems: 64,
485485
})
486+
487+
func (store *Store) cacheFile(file *entity.File) {
488+
fileCache.Set(file.ID, file, 256 /* 直接使用合理的均值以免进行实际计算消耗性能 */)
489+
}

0 commit comments

Comments
 (0)