diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index 7158d06..aba57ed 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -17,7 +17,7 @@ import ( //定时处理倒计时 func StartHttpTicker() { - for { + /*for { now := time.Now() //获取当前时间,放到now里面,要给next用 next := now.Add(time.Hour * 24) //通过now偏移24小时 next = time.Date(next.Year(), next.Month(), next.Day(), 0, 0, 0, 0, next.Location()) //获取下一个凌晨的日期 @@ -25,6 +25,19 @@ func StartHttpTicker() { <-t.C redishandler.GetRedisClient().Delete(redis.USER_SCORE_RANK) logger.Info("Del USER_SCORE_RANK success!") + }*/ + tick := time.Tick(500 * time.Millisecond) + for { + select { + case <-tick: + if time.Now().Hour() ==0 && time.Now().Minute() == 0 && time.Now().Second() <= 2 { + redishandler.GetRedisClient().Delete(redis.USER_SCORE_RANK) + logger.Info("Del USER_SCORE_RANK success!") + } + + default: + time.Sleep(100 * time.Millisecond) + } } } -- libgit2 0.21.0