mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-17 20:48:06 +01:00
🎨 Improve rhy cache duration
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
79e7339517
commit
535308f6ab
4 changed files with 16 additions and 9 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -214,10 +214,13 @@ var (
|
|||
subscriptionExpirationReminded bool
|
||||
)
|
||||
|
||||
func RefreshCheckJob() {
|
||||
func RefreshCheckJob2H() {
|
||||
go refreshSubscriptionExpirationRemind()
|
||||
go refreshUser()
|
||||
go refreshAnnouncement()
|
||||
}
|
||||
|
||||
func RefreshCheckJob6H() {
|
||||
go refreshCheckDownloadInstallPkg()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue