mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🎨 虚拟引用不再缓存关键字 Fix https://github.com/siyuan-note/siyuan/issues/6602
This commit is contained in:
parent
bec79ce100
commit
a1c74e4d90
3 changed files with 30 additions and 0 deletions
|
|
@ -215,6 +215,7 @@ func setSearch(c *gin.Context) {
|
||||||
if s.CaseSensitive != oldCaseSensitive {
|
if s.CaseSensitive != oldCaseSensitive {
|
||||||
model.FullReindex()
|
model.FullReindex()
|
||||||
}
|
}
|
||||||
|
sql.ClearVirtualRefKeywords()
|
||||||
ret.Data = s
|
ret.Data = s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func QueryVirtualRefKeywords(name, alias, anchor, doc bool) (ret []string) {
|
func QueryVirtualRefKeywords(name, alias, anchor, doc bool) (ret []string) {
|
||||||
|
ret, ok := getVirtualRefKeywordsCache()
|
||||||
|
if ok {
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
if name {
|
if name {
|
||||||
ret = append(ret, queryNames()...)
|
ret = append(ret, queryNames()...)
|
||||||
}
|
}
|
||||||
|
|
@ -44,6 +49,7 @@ func QueryVirtualRefKeywords(name, alias, anchor, doc bool) (ret []string) {
|
||||||
sort.SliceStable(ret, func(i, j int) bool {
|
sort.SliceStable(ret, func(i, j int) bool {
|
||||||
return len(ret[i]) >= len(ret[j])
|
return len(ret[i]) >= len(ret[j])
|
||||||
})
|
})
|
||||||
|
setVirtualRefKeywords(ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,29 @@ func removeBlockCache(id string) {
|
||||||
removeRefCacheByDefID(id)
|
removeRefCacheByDefID(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVirtualRefKeywordsCache() ([]string, bool) {
|
||||||
|
if disabled {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
if val, ok := memCache.Get("virtual_ref"); ok {
|
||||||
|
return val.([]string), true
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func setVirtualRefKeywords(keywords []string) {
|
||||||
|
if disabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
memCache.Set("virtual_ref", keywords, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ClearVirtualRefKeywords() {
|
||||||
|
memCache.Del("virtual_ref")
|
||||||
|
}
|
||||||
|
|
||||||
var defIDRefsCache = gcache.New(30*time.Minute, 5*time.Minute) // [defBlockID]map[refBlockID]*Ref
|
var defIDRefsCache = gcache.New(30*time.Minute, 5*time.Minute) // [defBlockID]map[refBlockID]*Ref
|
||||||
|
|
||||||
func GetRefsCacheByDefID(defID string) (ret []*Ref) {
|
func GetRefsCacheByDefID(defID string) (ret []*Ref) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue