Commit c22398ac1f54eb235928fd23bd65104b5ad228f7
1 parent
7b3a9e40
Exists in
master
提交
Showing
1 changed file
with
14 additions
and
1 deletions
Show diff stats
src/HttpServer/logic/httpserver.go
@@ -17,7 +17,7 @@ import ( | @@ -17,7 +17,7 @@ import ( | ||
17 | 17 | ||
18 | //定时处理倒计时 | 18 | //定时处理倒计时 |
19 | func StartHttpTicker() { | 19 | func StartHttpTicker() { |
20 | - for { | 20 | + /*for { |
21 | now := time.Now() //获取当前时间,放到now里面,要给next用 | 21 | now := time.Now() //获取当前时间,放到now里面,要给next用 |
22 | next := now.Add(time.Hour * 24) //通过now偏移24小时 | 22 | next := now.Add(time.Hour * 24) //通过now偏移24小时 |
23 | next = time.Date(next.Year(), next.Month(), next.Day(), 0, 0, 0, 0, next.Location()) //获取下一个凌晨的日期 | 23 | next = time.Date(next.Year(), next.Month(), next.Day(), 0, 0, 0, 0, next.Location()) //获取下一个凌晨的日期 |
@@ -25,6 +25,19 @@ func StartHttpTicker() { | @@ -25,6 +25,19 @@ func StartHttpTicker() { | ||
25 | <-t.C | 25 | <-t.C |
26 | redishandler.GetRedisClient().Delete(redis.USER_SCORE_RANK) | 26 | redishandler.GetRedisClient().Delete(redis.USER_SCORE_RANK) |
27 | logger.Info("Del USER_SCORE_RANK success!") | 27 | logger.Info("Del USER_SCORE_RANK success!") |
28 | + }*/ | ||
29 | + tick := time.Tick(500 * time.Millisecond) | ||
30 | + for { | ||
31 | + select { | ||
32 | + case <-tick: | ||
33 | + if time.Now().Hour() ==0 && time.Now().Minute() == 0 && time.Now().Second() <= 2 { | ||
34 | + redishandler.GetRedisClient().Delete(redis.USER_SCORE_RANK) | ||
35 | + logger.Info("Del USER_SCORE_RANK success!") | ||
36 | + } | ||
37 | + | ||
38 | + default: | ||
39 | + time.Sleep(100 * time.Millisecond) | ||
40 | + } | ||
28 | } | 41 | } |
29 | } | 42 | } |
30 | 43 |