func RedisGetTeamMsg(msgId uint64) ([]byte, error) { userKey := fmt.Sprintf("%s%d", KEY_TEAMMSGBUF, msgId) val, err := redis.RedisGet(userKey) if err != nil { return nil, errors.As(err, msgId) } return []byte(val), nil }
func RedisQueryTeam(tid uint64) (*TeamInfo, error) { userKey := fmt.Sprintf("%s%d", KEY_TEAM_INFO, tid) val, err := redis.RedisGet(userKey) if err != nil { return nil, errors.As(err, tid) } team := &TeamInfo{} if err := json.Unmarshal([]byte(val), team); err != nil { return nil, errors.As(err, string(val)) } return team, nil }
func RedisSetTeam(team *TeamInfo) error { userKey := fmt.Sprintf("%s%d", KEY_TEAM_INFO, team.TeamId) val, err := redis.RedisGet(userKey) if err != nil { return errors.As(err, *team) } var t TeamInfo err = json.Unmarshal([]byte(val), &t) if err != nil { return errors.As(err, *team) } if len(team.TeamName) > 1 { t.TeamName = team.TeamName } if len(team.CoreInfo) > 1 { t.CoreInfo = team.CoreInfo } if len(team.ExInfo) > 1 { t.ExInfo = team.ExInfo } b, err := json.Marshal(t) if err != nil { return errors.As(err, t) } userKey = fmt.Sprintf("%s%d", KEY_TEAM_INFO, team.TeamId) redis.RedisSet(userKey, string(b)) //info version val = fmt.Sprintf("%d", time.Now().Unix()) userKey = fmt.Sprintf("%s%d", KEY_TEAM_INFO_VER, team.TeamId) redis.RedisSet(userKey, val) return nil }