From 478888b39298bb033505a6c638652f6efa39c420 Mon Sep 17 00:00:00 2001 From: xing Date: Thu, 6 Oct 2022 21:35:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actions/common/common.go | 2 +- config.example.yaml | 2 ++ vars/config.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/actions/common/common.go b/actions/common/common.go index efee25a..e837da7 100644 --- a/actions/common/common.go +++ b/actions/common/common.go @@ -55,7 +55,7 @@ func InitActionsCommonCache() { maxPostIdCache = cache.NewSliceCache[uint64](getMaxPostId, vars.Conf.MaxPostIdCacheTime) - usersCache = cache.NewMapCacheByBatchFn[uint64, models.WpUsers](getUsers, time.Hour) + usersCache = cache.NewMapCacheByBatchFn[uint64, models.WpUsers](getUsers, vars.Conf.UserInfoCacheTime) usersCache.SetCacheFunc(getUser) } diff --git a/config.example.yaml b/config.example.yaml index 006ca33..d8ba217 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -49,3 +49,5 @@ maxRequestNum: 500 singleIpSearchNum: 10 # 文档最大id缓存时间 maxPostIdCacheTime: 1h +# 用户信息缓存时间 +userInfoCacheTime: 24h diff --git a/vars/config.go b/vars/config.go index 9f0159c..2243ce4 100644 --- a/vars/config.go +++ b/vars/config.go @@ -29,6 +29,7 @@ type Config struct { MaxRequestNum int64 `yaml:"maxRequestNum"` SingleIpSearchNum int64 `yaml:"singleIpSearchNum"` MaxPostIdCacheTime time.Duration `yaml:"maxPostIdCacheTime"` + UserInfoCacheTime time.Duration `yaml:"userInfoCacheTime"` } type Mysql struct {