Browse Source

:arrow_up: Upgrade kernel deps

Daniel 9 months ago
parent
commit
c765bcc36f
5 changed files with 12 additions and 12 deletions
  1. 4 4
      kernel/cache/ial.go
  2. 1 1
      kernel/go.mod
  3. 2 2
      kernel/go.sum
  4. 3 3
      kernel/model/virutalref.go
  5. 2 2
      kernel/sql/cache.go

+ 4 - 4
kernel/cache/ial.go

@@ -23,7 +23,7 @@ import (
 	"github.com/dgraph-io/ristretto"
 )
 
-var docIALCache, _ = ristretto.NewCache(&ristretto.Config{
+var docIALCache, _ = ristretto.NewCache[string, map[string]string](&ristretto.Config[string, map[string]string]{
 	NumCounters: 1024 * 100,
 	MaxCost:     1024 * 1024 * 200,
 	BufferItems: 64,
@@ -40,7 +40,7 @@ func GetDocIAL(p string) (ret map[string]string) {
 	}
 
 	ret = map[string]string{}
-	for k, v := range ial.(map[string]string) {
+	for k, v := range ial {
 		ret[k] = strings.ReplaceAll(v, editor.IALValEscNewLine, "\n")
 	}
 	return
@@ -54,7 +54,7 @@ func ClearDocsIAL() {
 	docIALCache.Clear()
 }
 
-var blockIALCache, _ = ristretto.NewCache(&ristretto.Config{
+var blockIALCache, _ = ristretto.NewCache[string, map[string]string](&ristretto.Config[string, map[string]string]{
 	NumCounters: 1024 * 1000,
 	MaxCost:     1024 * 1024 * 200,
 	BufferItems: 64,
@@ -69,7 +69,7 @@ func GetBlockIAL(id string) (ret map[string]string) {
 	if nil == ial {
 		return
 	}
-	return ial.(map[string]string)
+	return ial
 }
 
 func RemoveBlockIAL(id string) {

+ 1 - 1
kernel/go.mod

@@ -54,7 +54,7 @@ require (
 	github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
 	github.com/sashabaranov/go-openai v1.29.1
 	github.com/shirou/gopsutil/v3 v3.24.5
-	github.com/siyuan-note/dejavu v0.0.0-20240922022610-033cc35db309
+	github.com/siyuan-note/dejavu v0.0.0-20240922023411-ba02dd7afac9
 	github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4
 	github.com/siyuan-note/eventbus v0.0.0-20240627125516-396fdb0f0f97
 	github.com/siyuan-note/filelock v0.0.0-20240724034355-d1ed7bf21d04

+ 2 - 2
kernel/go.sum

@@ -332,8 +332,8 @@ github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+D
 github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d h1:lvCTyBbr36+tqMccdGMwuEU+hjux/zL6xSmf5S9ITaA=
 github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw=
 github.com/simplereach/timeutils v1.2.0/go.mod h1:VVbQDfN/FHRZa1LSqcwo4kNZ62OOyqLLGQKYB3pB0Q8=
-github.com/siyuan-note/dejavu v0.0.0-20240922022610-033cc35db309 h1:jo6rn0qK4YEXlRvNrZzHC/zdOErCNh61ad57EO8O0ow=
-github.com/siyuan-note/dejavu v0.0.0-20240922022610-033cc35db309/go.mod h1:3Hl2ttBIdfRMhzJ+WEvbuYokL3JLSMj8jObn96hrWt4=
+github.com/siyuan-note/dejavu v0.0.0-20240922023411-ba02dd7afac9 h1:TRIWGA/sP4T2eAEJSNpNhct8iGHDIGyXEtSnq2FYnwQ=
+github.com/siyuan-note/dejavu v0.0.0-20240922023411-ba02dd7afac9/go.mod h1:3Hl2ttBIdfRMhzJ+WEvbuYokL3JLSMj8jObn96hrWt4=
 github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4 h1:kJaw5L/evyW6LcB9IQT8PR4ppx8JVqOFP9Ix3rfwSrc=
 github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4/go.mod h1:UYcCCY+0wh+GmUoDOaO63j1sV5lgy7laLAk1XhEiUis=
 github.com/siyuan-note/eventbus v0.0.0-20240627125516-396fdb0f0f97 h1:lM5v8BfNtbOL5jYwhCdMYBcYtr06IYBKjjSLAPMKTM8=

+ 3 - 3
kernel/model/virutalref.go

@@ -37,7 +37,7 @@ import (
 
 // virtualBlockRefCache 用于保存块关联的虚拟引用关键字。
 // 改进打开虚拟引用后加载文档的性能 https://github.com/siyuan-note/siyuan/issues/7378
-var virtualBlockRefCache, _ = ristretto.NewCache(&ristretto.Config{
+var virtualBlockRefCache, _ = ristretto.NewCache[string, []string](&ristretto.Config[string, []string]{
 	NumCounters: 102400,
 	MaxCost:     10240,
 	BufferItems: 64,
@@ -60,7 +60,7 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {
 		ret = putBlockVirtualRefKeywords(content, root)
 		return
 	}
-	ret = val.([]string)
+	ret = val
 	return
 }
 
@@ -216,7 +216,7 @@ func getVirtualRefKeywords(root *ast.Node) (ret []string) {
 	}
 
 	if val, ok := virtualBlockRefCache.Get("virtual_ref"); ok {
-		ret = val.([]string)
+		ret = val
 	}
 
 	if "" != strings.TrimSpace(Conf.Editor.VirtualBlockRefInclude) {

+ 2 - 2
kernel/sql/cache.go

@@ -37,7 +37,7 @@ func disableCache() {
 	cacheDisabled = true
 }
 
-var blockCache, _ = ristretto.NewCache(&ristretto.Config{
+var blockCache, _ = ristretto.NewCache[string, *Block](&ristretto.Config[string, *Block]{
 	NumCounters: 102400,
 	MaxCost:     10240,
 	BufferItems: 64,
@@ -67,7 +67,7 @@ func getBlockCache(id string) (ret *Block) {
 
 	b, _ := blockCache.Get(id)
 	if nil != b {
-		ret = b.(*Block)
+		ret = b
 	}
 	return
 }