注释内存中的战斗缓存
parent
fe14a4230f
commit
01771b2fde
|
@ -46,24 +46,23 @@ public class FightRecordLogic {
|
||||||
|
|
||||||
public void addRecordMap(User user, CommonProto.FightData fightData) throws JsonProcessingException {
|
public void addRecordMap(User user, CommonProto.FightData fightData) throws JsonProcessingException {
|
||||||
// 玩家id
|
// 玩家id
|
||||||
int uid = user.getId();
|
// int uid = user.getId();
|
||||||
// 战斗类型
|
// // 战斗类型
|
||||||
int multiKey = fightData.getFightType();
|
// int multiKey = fightData.getFightType();
|
||||||
// 获取玩家的战斗数据
|
// // 获取玩家的战斗数据
|
||||||
MultiValueMap<Integer, String> multiValueMap = recordMap.getOrDefault(uid, new LinkedMultiValueMap<Integer, String>());
|
// MultiValueMap<Integer, String> multiValueMap = recordMap.getOrDefault(uid, new LinkedMultiValueMap<Integer, String>());
|
||||||
// 根据类型获取战斗数据
|
// // 根据类型获取战斗数据
|
||||||
List<String> strings = multiValueMap.getOrDefault(multiKey,new ArrayList<>());
|
// List<String> strings = multiValueMap.getOrDefault(multiKey,new ArrayList<>());
|
||||||
// 类型大于十条删除最早的一条
|
// // 类型大于十条删除最早的一条
|
||||||
if (strings.size() >= max){
|
// if (strings.size() >= max){
|
||||||
strings.remove(0);
|
// strings.remove(0);
|
||||||
}
|
// }
|
||||||
// protobuf转字符串
|
// // protobuf转字符串
|
||||||
String str = JsonFormat.printToString(fightData);
|
// String str = JsonFormat.printToString(fightData);
|
||||||
strings.add(str);
|
// strings.add(str);
|
||||||
// 重新赋值
|
// // 重新赋值
|
||||||
multiValueMap.put(multiKey,strings);
|
// multiValueMap.put(multiKey,strings);
|
||||||
// System.out.println("fightId======================="+fightData.getFightId());
|
// recordMap.put(uid,multiValueMap);
|
||||||
recordMap.put(uid,multiValueMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue