golang 使用redis
package model import ( "github.com/go-redis/redis" "log" "time" ) var RedisClient *redis.Client func InitRedis() { RedisClient = redis.NewClient(&redis.Options{ Addr: "127.0.0.1:6379", Password: "", // no password set DB: 0, // use default DB }) _, redisErr := RedisClient.Ping().Result() if redisErr != nil { log.Println("redis 连接失败") } else { log.Println("Init Redis Successful") } //RedisClient := model.RedisClient //二十五小时过期 RedisClient.Set("app:hb:hk:01", time.Now().Unix(), 1000000000*60*60*25) }