Example #1
0
func RedisAddTeamMember(tid, uid uint64) error {
	count := RedisTeamMemberCount(tid)
	if int(count) >= MAX_MEMBER_NUM_TEAM {
		return errors.New("team member too many")
	}
	userKey := fmt.Sprintf("%s%d", SET_TEAM_MEMBER, tid)
	val := fmt.Sprintf("%d", uid)

	redis.RedisSAdd(userKey, val)

	//member version
	val = fmt.Sprintf("%d", time.Now().Unix())
	userKey = fmt.Sprintf("%s%d", KEY_TEAM_MEMBER_VER, tid)
	redis.RedisSet(userKey, val)

	userKey = fmt.Sprintf("%s%d", SET_USERS_TEAM, uid)
	val = fmt.Sprintf("%d", tid)
	redis.RedisSAdd(userKey, val)

	return nil
}
Example #2
0
func RedisCreateTeam(team *TeamInfo) error {
	b, err := json.Marshal(*team)
	if err != nil {
		return errors.As(err, *team)
	}

	userKey := fmt.Sprintf("%s%d", KEY_TEAM_INFO, team.TeamId)
	redis.RedisSet(userKey, string(b))

	userKey = fmt.Sprintf("%s%d", SET_USERS_TEAM, team.Uid)
	val := fmt.Sprintf("%d", team.TeamId)

	redis.RedisSAdd(userKey, val)

	//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
}