26 lines
492 B
Go
Raw Normal View History

2025-06-10 22:29:29 +08:00
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()
}