Exemplo n.º 1
0
//更新用户最后登录时间
func UpdateUserLastLoginTime(identification uint64, userID uint64, time int64) {
	msg := dbProto.MarshalProtoMsg(identification, &dbProto.DB_User_UpdateLastLoginTimeC2S{
		UserID: protos.Uint64(userID),
		Time:   protos.Int64(time),
	})
	sendDBMsgToServer(msg)
}
func sendCommonLog(dir string, logType uint32, content string) {
	send_msg := protos.MarshalProtoMsg(&logProto.Log_CommonLogC2S{
		Dir:     protos.String(dir),
		Type:    protos.Uint32(logType),
		Content: protos.String(content),
		Time:    protos.Int64(time.Now().Unix()),
	})
	sendLogMsgToServer(send_msg)
}
//更新用户最后登录时间
func UpdateUserLastLoginTime(dbUser *DBUserModel) {
	userIDStr := strconv.FormatUint(dbUser.ID, 10)
	userLastLoginTime := strconv.FormatInt(dbUser.LastLoginTime, 10)

	//更新内存
	userKey := DB_User_Key + userIDStr
	data, _ := json.Marshal(dbUser)
	client.Set(userKey, data)

	//单独设置用户的最后登录时间,清理用户缓存数据使用
	client.Hset(DB_UserLastLoginTime_Key, userIDStr, []byte(userLastLoginTime))

	//更新DB
	msg := dbProto.MarshalProtoMsg(0, &dbProto.DB_User_UpdateLastLoginTimeC2S{
		UserID: protos.Uint64(dbUser.ID),
		Time:   protos.Int64(dbUser.LastLoginTime),
	})
	PushDBWriteMsg(msg)
}