package model import ( "context" "encoding/json" "game/common/proto/pb" ) const ( trendKey = "ColorTrend" ) // 获取历史路途数据 func GetTrend() [][]pb.ColorType { v := UserRedis.Get(context.Background(), trendKey).Val() trend := make([][]pb.ColorType, 0) _ = json.Unmarshal([]byte(v), &trend) return trend } // 保存路途数据 func SetTrend(trend [][]pb.ColorType) { v, _ := json.Marshal(trend) _ = UserRedis.Set(context.Background(), trendKey, string(v), 0).Err() }