🎨 Caching tree data to improve performance and reduce disk read operations https://github.com/siyuan-note/siyuan/issues/16961 https://github.com/siyuan-note/siyuan/issues/16991

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-02-10 09:26:18 +08:00
parent ca931e64d4
commit 6c60df3d55
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -292,23 +292,23 @@ func removeIndexes(removeFilePaths []string) (removeRootIDs []string) {
continue
}
id := util.GetTreeID(removeFile)
removeRootIDs = append(removeRootIDs, id)
block := treenode.GetBlockTree(id)
if nil != block {
msg := fmt.Sprintf(Conf.Language(39), block.RootID)
util.IncBootProgress(bootProgressPart, msg)
util.PushStatusBar(msg)
rootID := util.GetTreeID(removeFile)
removeRootIDs = append(removeRootIDs, rootID)
bts := treenode.GetBlockTreesByRootID(block.RootID)
for _, b := range bts {
cache.RemoveBlockIAL(b.ID)
}
cache.RemoveDocIAL(block.Path)
msg := fmt.Sprintf(Conf.Language(39), rootID)
util.IncBootProgress(bootProgressPart, msg)
util.PushStatusBar(msg)
treenode.RemoveBlockTreesByRootID(block.RootID)
sql.RemoveTreeQueue(block.RootID)
cache.RemoveTreeData(rootID)
sql.RemoveTreeQueue(rootID)
bts := treenode.GetBlockTreesByRootID(rootID)
for _, b := range bts {
cache.RemoveBlockIAL(b.ID)
}
if block := treenode.GetBlockTree(rootID); nil != block {
cache.RemoveDocIAL(block.Path)
}
treenode.RemoveBlockTreesByRootID(rootID)
}
if 1 > len(removeRootIDs) {
@ -341,6 +341,8 @@ func upsertIndexes(upsertFilePaths []string) (upsertRootIDs []string) {
util.IncBootProgress(bootProgressPart, msg)
util.PushStatusBar(msg)
rootID := util.GetTreeID(p)
cache.RemoveTreeData(rootID)
tree, err0 := filesys.LoadTree(box, p, luteEngine)
if nil != err0 {
continue
@ -348,13 +350,13 @@ func upsertIndexes(upsertFilePaths []string) (upsertRootIDs []string) {
treenode.UpsertBlockTree(tree)
sql.UpsertTreeQueue(tree)
bts := treenode.GetBlockTreesByRootID(tree.ID)
bts := treenode.GetBlockTreesByRootID(rootID)
for _, b := range bts {
cache.RemoveBlockIAL(b.ID)
}
cache.RemoveDocIAL(tree.Path)
upsertRootIDs = append(upsertRootIDs, tree.Root.ID)
upsertRootIDs = append(upsertRootIDs, rootID)
}
if 1 > len(upsertRootIDs) {