Forráskód Böngészése

wip:bxcore 调整缓存时间

fuwencai 3 hónapja
szülő
commit
7f7027b1ee
1 módosított fájl, 14 hozzáadás és 1 törlés
  1. 14 1
      jyBXCore/rpc/internal/logic/getsearchlistlogic.go

+ 14 - 1
jyBXCore/rpc/internal/logic/getsearchlistlogic.go

@@ -157,7 +157,7 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 		if in.UserId != "" {
 			key := fmt.Sprintf(TaskActivityCacheKey, in.PositionId, TaskActiveId, TaskIdSearch)
 			if exist, _ := redis.Exists("other", key); !exist {
-				redis.Put("other", key, 1, TaskActivityCacheTimeout)
+				redis.Put("other", key, 1, GetLastTime())
 				nsqNode := jy.Jyweb_node2
 				if in.Platform == "WX" {
 					nsqNode = jy.Jywx_node1
@@ -273,3 +273,16 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 		ErrCode: 0,
 	}, nil
 }
+func GetLastTime() int {
+	n := TaskActivityCacheTimeout
+	t := time.Now()
+	midnight := time.Date(t.Year(), t.Month(), t.Day()+1, 0, 0, 0, 0, t.Location())
+	if midnight.After(t) {
+		if int(midnight.Unix()-t.Unix()) > n {
+			return n
+		} else {
+			return int(midnight.Unix() - t.Unix())
+		}
+	}
+	return n
+}