Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve rhy cache duration

Daniel535308f6ab90
diff --git a/kernel/bazaar/package.go b/kernel/bazaar/package.go
index 85a132e362..cae1efc29e 100644
--- a/kernel/bazaar/package.go
+++ b/kernel/bazaar/package.go
@@ -575,7 +575,7 @@ func getStageIndex(pkgType string) (ret *StageIndex, err error) {
defer stageIndexLock.Unlock()
now := time.Now().Unix()
- if 3600 >= now-stageIndexCacheTime && nil != cachedStageIndex[pkgType] {
+ if util.RhyCacheDuration >= now-stageIndexCacheTime && nil != cachedStageIndex[pkgType] {
ret = cachedStageIndex[pkgType]
return
}
diff --git a/kernel/job/cron.go b/kernel/job/cron.go
index 2610cae76c..075c7bc497 100644
--- a/kernel/job/cron.go
+++ b/kernel/job/cron.go
@@ -33,7 +33,8 @@ func StartCron() {
go every(5*time.Second, model.SyncDataJob)
go every(2*time.Hour, model.StatJob)
go every(6*time.Hour, util.RefreshRhyResultJob, "RefreshRhyResultJob")
- go every(2*time.Hour, model.RefreshCheckJob)
+ go every(2*time.Hour, model.RefreshCheckJob2H)
+ go every(6*time.Hour, model.RefreshCheckJob6H)
go every(3*time.Second, model.FlushUpdateRefTextRenameDocJob)
go every(util.SQLFlushInterval, sql.FlushTxJob)
go every(util.SQLFlushInterval, sql.FlushHistoryTxJob)
diff --git a/kernel/model/cloud_service.go b/kernel/model/cloud_service.go
index 9b9a14c658..6e4c7e8b2c 100644
--- a/kernel/model/cloud_service.go
+++ b/kernel/model/cloud_service.go
@@ -214,10 +214,13 @@ var (
subscriptionExpirationReminded bool
)
-func RefreshCheckJob() {
+func RefreshCheckJob2H() {
go refreshSubscriptionExpirationRemind()
go refreshUser()
go refreshAnnouncement()
+}
+
+func RefreshCheckJob6H() {
go refreshCheckDownloadInstallPkg()
}
diff --git a/kernel/util/rhy.go b/kernel/util/rhy.go
index bbb37ac928..bca7d8b54d 100644
--- a/kernel/util/rhy.go
+++ b/kernel/util/rhy.go
@@ -26,21 +26,24 @@ import (
"github.com/siyuan-note/logging"
)
-var cachedRhyResult = map[string]interface{}{}
-var rhyResultCacheTime int64
-var rhyResultLock = sync.Mutex{}
+var (
+ RhyCacheDuration = int64(3600 * 6)
+
+ cachedRhyResult = map[string]interface{}{}
+ rhyResultCacheTime int64
+ rhyResultLock = sync.Mutex{}
+)
func GetRhyResult(force bool) (map[string]interface{}, error) {
rhyResultLock.Lock()
defer rhyResultLock.Unlock()
- cacheDuration := int64(3600 * 6)
if ContainerDocker == Container {
- cacheDuration = int64(3600 * 24)
+ RhyCacheDuration = int64(3600 * 24)
}
now := time.Now().Unix()
- if cacheDuration >= now-rhyResultCacheTime && !force && 0 < len(cachedRhyResult) {
+ if RhyCacheDuration >= now-rhyResultCacheTime && !force && 0 < len(cachedRhyResult) {
return cachedRhyResult, nil
}