#4896 修改代码,增加缓存时间及动态更新缓存

Merged
ychao_1983 merged 2 commits from zouap_dev into V20231120 5 months ago
  1. +3
    -1
      routers/repo/attachment_dir.go

+ 3
- 1
routers/repo/attachment_dir.go View File

@@ -37,6 +37,8 @@ func GetDirSomeFiles(ctx *context.Context) {
cacheResult, err := getAttachmentDirFromCache(cacheKey)
if err == nil {
log.Info("load from cache.")
//update redis status
setAttachmentDirToCache(cacheKey, *cacheResult)
ctx.JSON(200, map[string]interface{}{
"result_code": "0",
"data": cacheResult.DirList,
@@ -338,7 +340,7 @@ func setAttachmentDirToCache(msgKey string, dirList DirRedisCache) {
msgMapJson, _ := json.Marshal(dirList)
redisValue := string(msgMapJson)
log.Info("set redis key=" + msgKey + " value=" + redisValue)
re, err := redis_client.Setex(msgKey, redisValue, 7*24*3600*time.Second)
re, err := redis_client.Setex(msgKey, redisValue, 30*24*3600*time.Second)
if err == nil {
log.Info("re =" + fmt.Sprint(re))
} else {


Loading…
Cancel
Save