mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
⚡ 改进块引搜索性能 Fix https://github.com/siyuan-note/siyuan/issues/6655
This commit is contained in:
parent
4650eec7c6
commit
b6e6c35f9f
2 changed files with 10 additions and 1 deletions
|
|
@ -502,6 +502,7 @@ func scanBlockRow(row *sql.Row) (ret *Block) {
|
|||
return
|
||||
}
|
||||
ret = &block
|
||||
putBlockCache(ret)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ import (
|
|||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/dgraph-io/ristretto"
|
||||
"github.com/jinzhu/copier"
|
||||
gcache "github.com/patrickmn/go-cache"
|
||||
"github.com/siyuan-note/logging"
|
||||
)
|
||||
|
||||
var memCache, _ = ristretto.NewCache(&ristretto.Config{
|
||||
|
|
@ -50,7 +52,13 @@ func putBlockCache(block *Block) {
|
|||
if disabled {
|
||||
return
|
||||
}
|
||||
memCache.Set(block.ID, block, 1)
|
||||
|
||||
cloned := &Block{}
|
||||
if err := copier.Copy(cloned, block); nil != err {
|
||||
logging.LogErrorf("clone block failed: %v", err)
|
||||
return
|
||||
}
|
||||
memCache.Set(cloned.ID, cloned, 1)
|
||||
}
|
||||
|
||||
func getBlockCache(id string) (ret *Block) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue