redis key 优化
parent
772420df81
commit
b24f82df04
|
@ -56,6 +56,7 @@ public interface GlobalsDef {
|
|||
|
||||
//redis 过期时间
|
||||
int REDIS_OVER_TIME = -1;
|
||||
int REDIS_OVER_TIME_DAY = 86400;
|
||||
|
||||
//吃食物相关
|
||||
int FOOD_ADDITION_BATTLE_TYPE = 1;
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package com.ljsd.jieling.handler.Expedition;
|
||||
|
||||
import com.ljsd.fight.FightType;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
@ -108,7 +110,7 @@ public class StartExpeditionBattleRequest extends BaseHandler<Expedition.StartEx
|
|||
int seed = (int)(System.currentTimeMillis()/1000);
|
||||
String fightInfo = nodeId + "#" +seed+ "#" + teamId;
|
||||
String key = RedisKey.getKey(RedisKey.CHALLENGE_EXPEDITION_INFO, String.valueOf(iSession.getUid()), false);
|
||||
RedisUtil.getInstence().set(key, fightInfo, -1);
|
||||
RedisUtil.getInstence().set(key, fightInfo, GlobalsDef.REDIS_OVER_TIME_DAY);
|
||||
|
||||
|
||||
FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder();
|
||||
|
|
|
@ -2113,7 +2113,7 @@ public class MapLogic {
|
|||
String fightInfo = fightId + "#" + teamId;
|
||||
String key = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_INFO, String.valueOf(uid), false);
|
||||
LOGGER.info("关卡战斗start{},{}",uid,fightInfo);
|
||||
RedisUtil.getInstence().set(key, fightInfo, -1);
|
||||
RedisUtil.getInstence().set(key, fightInfo, 600);
|
||||
//扣除预先道具
|
||||
FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder();
|
||||
BehaviorUtil.getLevelDifficultyifficuFightInfo(user, FightType.StoryFight,sMainLevelConfig.getMonsterGroup(), teamId, sMainLevelConfig.getRankTime(), fightStartResponse, RedisKey.LEVE_DIFFICULTY_FIGHT);
|
||||
|
@ -2264,6 +2264,7 @@ public class MapLogic {
|
|||
LOGGER.info("endFight() uid=>{} fightKey={},fightId={} fightInfos == null", uid, fightKey);
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
RedisUtil.getInstence().del(fightKey);
|
||||
String[] split = fightInfos.split("#");
|
||||
int checkFightId = Integer.parseInt(split[0]);
|
||||
SFloodConfig sFloodConfig = STableManager.getConfig(SFloodConfig.class).get(checkFightId);
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ljsd.jieling.network.server;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
|
@ -276,13 +277,13 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
LOGGER.info("the uid={} offline.the indication size={}", session.getUid(), indexToIndication.size());
|
||||
if (!indexToIndication.isEmpty()) {
|
||||
String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(session.getUid()));
|
||||
RedisUtil.getInstence().set(key, gson.toJson(indexToIndication));
|
||||
RedisUtil.getInstence().set(key, gson.toJson(indexToIndication), GlobalsDef.REDIS_OVER_TIME_DAY);
|
||||
}
|
||||
String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_INDEX, Integer.toString(session.getUid()));
|
||||
RedisUtil.getInstence().set(key, String.valueOf(session.getIndicationIndex()));
|
||||
RedisUtil.getInstence().set(key, String.valueOf(session.getIndicationIndex()), GlobalsDef.REDIS_OVER_TIME_DAY);
|
||||
|
||||
key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
RedisUtil.getInstence().set(key, gson.toJson(session.getIndexToMessage()));
|
||||
RedisUtil.getInstence().set(key, gson.toJson(session.getIndexToMessage()), GlobalsDef.REDIS_OVER_TIME_DAY);
|
||||
}
|
||||
|
||||
private int checkIndex(ISession iSession, PacketNetData packetNetData) {
|
||||
|
|
Loading…
Reference in New Issue