mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-22 23:14:07 +01:00
♻️ Improve database loading performance https://github.com/siyuan-note/siyuan/issues/12818
This commit is contained in:
parent
c42064ec0b
commit
95c82187af
6 changed files with 33 additions and 53 deletions
|
|
@ -493,7 +493,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
|
|||
waitForSyncingStorages()
|
||||
|
||||
ret = []*BlockAttributeViewKeys{}
|
||||
attrs := sql.GetBlockAttrsWithoutWaitWriting(blockID)
|
||||
attrs := sql.GetBlockAttrs(blockID)
|
||||
avs := attrs[av.NodeAttrNameAvs]
|
||||
if "" == avs {
|
||||
return
|
||||
|
|
@ -631,7 +631,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
|
|||
kv.Values[0].Created = av.NewFormattedValueCreated(time.Now().UnixMilli(), 0, av.CreatedFormatNone)
|
||||
}
|
||||
case av.KeyTypeUpdated:
|
||||
ial := sql.GetBlockAttrsWithoutWaitWriting(blockID)
|
||||
ial := sql.GetBlockAttrs(blockID)
|
||||
updatedStr := ial["updated"]
|
||||
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
|
||||
if nil == parseErr {
|
||||
|
|
@ -655,7 +655,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
|
|||
ial := map[string]string{}
|
||||
block := av.GetKeyBlockValue(keyValues)
|
||||
if nil != block && !block.IsDetached {
|
||||
ial = sql.GetBlockAttrsWithoutWaitWriting(block.BlockID)
|
||||
ial = sql.GetBlockAttrs(block.BlockID)
|
||||
}
|
||||
|
||||
if nil == kv.Values[0].Template {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import (
|
|||
"github.com/88250/lute/parse"
|
||||
"github.com/araddon/dateparse"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
|
|
@ -51,7 +50,9 @@ func SetBlockReminder(id string, timed string) (err error) {
|
|||
timedMills = t.UnixMilli()
|
||||
}
|
||||
|
||||
attrs := GetBlockAttrs(id) // 获取属性是会等待树写入
|
||||
WaitForWritingFiles()
|
||||
|
||||
attrs := sql.GetBlockAttrs(id)
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -283,34 +284,3 @@ func ResetBlockAttrs(id string, nameValues map[string]string) (err error) {
|
|||
cache.RemoveBlockIAL(id)
|
||||
return
|
||||
}
|
||||
|
||||
func BatchGetBlockAttrs(ids []string) (ret map[string]map[string]string) {
|
||||
WaitForWritingFiles()
|
||||
|
||||
ret = map[string]map[string]string{}
|
||||
trees := filesys.LoadTrees(ids)
|
||||
for _, id := range ids {
|
||||
tree := trees[id]
|
||||
if nil == tree {
|
||||
continue
|
||||
}
|
||||
|
||||
ret[id] = sql.GetBlockAttrs0(id, tree)
|
||||
cache.PutBlockIAL(id, ret[id])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetBlockAttrs(id string) (ret map[string]string) {
|
||||
ret = map[string]string{}
|
||||
if cached := cache.GetBlockIAL(id); nil != cached {
|
||||
ret = cached
|
||||
return
|
||||
}
|
||||
|
||||
WaitForWritingFiles()
|
||||
|
||||
ret = sql.GetBlockAttrs(id)
|
||||
cache.PutBlockIAL(id, ret)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -598,7 +598,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash
|
|||
newCardLimit := Conf.Flashcard.NewCardLimit
|
||||
reviewCardLimit := Conf.Flashcard.ReviewCardLimit
|
||||
// 文档级新卡/复习卡上限控制 Document-level new card/review card limit control https://github.com/siyuan-note/siyuan/issues/9365
|
||||
ial := GetBlockAttrs(rootID)
|
||||
ial := sql.GetBlockAttrs(rootID)
|
||||
if newCardLimitStr := ial["custom-riff-new-card-limit"]; "" != newCardLimitStr {
|
||||
var convertErr error
|
||||
newCardLimit, convertErr = strconv.Atoi(newCardLimitStr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue