golang定时器与redis结合,每隔1秒ping一下,每隔20秒llen一下队列的长度
package main import ( "fmt" time" github.com/go-redis/redis" ) var ( client *redis.Client ) func main() { client = redis.NewClient(&redis.Options{ Addr: xxx:xxxx,Password: ""0time.NewTicker(time.Second) t1 := time.Second * 20) for { selectcase <-t.C: pong,_ := client.Ping().Result() fmt.Println(pong) t1.C: num,_ := client.LLen(ent_imap_lz).Result() fmt.Println(队列数量