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 {