Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-11-21 10:40:42 +08:00
commit 79d3a3e7db
3 changed files with 16 additions and 2 deletions

View file

@ -378,7 +378,12 @@ func fullTextSearchCount(query, box, path, filter string) (matchedBlockCount, ma
return
}
stmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `blocks_fts` WHERE `blocks_fts` MATCH '" + columnFilter() + ":(" + query + ")' AND type IN " + filter
table := "blocks_fts" // 大小写敏感
if !Conf.Search.CaseSensitive {
table = "blocks_fts_case_insensitive"
}
stmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `" + table + "` WHERE `" + table + "` MATCH '" + columnFilter() + ":(" + query + ")' AND type IN " + filter
if "" != box {
stmt += " AND box = '" + box + "'"
}

View file

@ -502,6 +502,7 @@ func scanBlockRow(row *sql.Row) (ret *Block) {
return
}
ret = &block
putBlockCache(ret)
return
}

View file

@ -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) {