rediskey修改
parent
e086fd1e97
commit
dff49eded3
|
@ -246,7 +246,7 @@ public class RedisKey {
|
|||
public static final String GUILD_SHEJI_SCORE_RANK = "GUILD_SHEJI_SCORE_RANK";
|
||||
|
||||
|
||||
public static final String DEATH_PAHT_TOTAL_CHALLENGE_COUNT = "DEATH_PAHT_TOTAL_CHALLENGE_COUNT";
|
||||
public static final String DEATH_PATH_TOTAL_CHALLENGE_COUNT = "DEATH_PATH_TOTAL_CHALLENGE_COUNT";
|
||||
|
||||
|
||||
public final static String CAR_CHALLENGE_RECORD = "CAR_CHALLENGE_RECORD"; //车迟玩法挑战记录
|
||||
|
|
|
@ -61,10 +61,12 @@ public class RedisUtil {
|
|||
|
||||
|
||||
public Cursor<String> scan(String match, int count){
|
||||
ScanOptions scanOptions = ScanOptions.scanOptions().match(match).count(count).build();
|
||||
ScanOptions.ScanOptionsBuilder match1 = ScanOptions.scanOptions().match(match);
|
||||
if(count!=-1)
|
||||
match1.count(count);
|
||||
RedisSerializer<String> redisSerializer = (RedisSerializer<String>) redisTemplate.getKeySerializer();
|
||||
return (Cursor) redisTemplate.executeWithStickyConnection((RedisCallback) redisConnection ->
|
||||
new ConvertingCursor<>(redisConnection.scan(scanOptions), redisSerializer::deserialize));
|
||||
new ConvertingCursor<>(redisConnection.scan(match1.build()), redisSerializer::deserialize));
|
||||
}
|
||||
/**
|
||||
* 指定缓存失效时间
|
||||
|
|
|
@ -390,14 +390,14 @@ public class DeathPathLogic {
|
|||
private void taskDoExecute(DeathPathTask task){
|
||||
|
||||
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(task.getGuildId()), DeathChallengeCount.class);
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, String.valueOf(task.getGuildId()), DeathChallengeCount.class);
|
||||
if (countInfo==null){
|
||||
countInfo = new DeathChallengeCount();
|
||||
countInfo.putUserReward(task.getUid(),new DeathReward());
|
||||
RedisUtil.getInstence().set(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(task.getGuildId()),countInfo);
|
||||
RedisUtil.getInstence().set(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, String.valueOf(task.getGuildId()),countInfo);
|
||||
}else if(!countInfo.getUserReward().containsKey(task.getUid())) {
|
||||
countInfo.putUserReward(task.getUid(),new DeathReward());
|
||||
RedisUtil.getInstence().set(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(task.getGuildId()), countInfo);
|
||||
RedisUtil.getInstence().set(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, String.valueOf(task.getGuildId()), countInfo);
|
||||
}
|
||||
//跨服
|
||||
if(task.getGroupId()>0){
|
||||
|
@ -492,7 +492,7 @@ public class DeathPathLogic {
|
|||
*/
|
||||
public void getAllRewardInfo(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(user.getPlayerInfoManager().getGuildId()), DeathChallengeCount.class);
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, String.valueOf(user.getPlayerInfoManager().getGuildId()), DeathChallengeCount.class);
|
||||
Family.GetAllDeathPathRewardInfoResponse.Builder response = Family.GetAllDeathPathRewardInfoResponse.newBuilder();
|
||||
if(countInfo==null){
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
|
@ -522,7 +522,7 @@ public class DeathPathLogic {
|
|||
User user = UserManager.getUser(uid);
|
||||
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(guildId), DeathChallengeCount.class);
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, String.valueOf(guildId), DeathChallengeCount.class);
|
||||
if (countInfo==null||!countInfo.getUserReward().containsKey(uid)){
|
||||
//您所在的公会或您没有达到领奖条件
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
|
@ -547,7 +547,7 @@ public class DeathPathLogic {
|
|||
}
|
||||
int[] reward = getRewardByRank(rank);
|
||||
countInfo.putUserReward(uid,new DeathReward(reward[0],reward[1],position,user.getPlayerInfoManager().getNickName()));
|
||||
RedisUtil.getInstence().set(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(guildId),countInfo);
|
||||
RedisUtil.getInstence().set(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, String.valueOf(guildId),countInfo);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[][]{reward}, BIReason.DEATH_PAHT_RANDOM_REWARD);
|
||||
Family.DoRewardDeathPathResponse response =Family.DoRewardDeathPathResponse.newBuilder().setDrop(drop).build();
|
||||
Family.RewardInfo info = Family.RewardInfo.newBuilder().setUid(uid).setItemCount(reward[1]).setItemId(reward[0]).setPosition(position).setUsername(user.getPlayerInfoManager().getNickName()).build();
|
||||
|
@ -580,9 +580,10 @@ public class DeathPathLogic {
|
|||
String mailTitle = SErrorCodeEerverConfig.getI18NMessage("guildwar_reward_title");
|
||||
String mailContent = SErrorCodeEerverConfig.getI18NMessage("guildwar_reward_txt");
|
||||
|
||||
int serverId = GameApplication.serverId;
|
||||
if(groupId>0){
|
||||
//是否跨服
|
||||
WorldProto.DeathPathWorldRewardResponse rewardResponse = WorldHelper.sendMessageToWorldWithResult(0, WorldProto.DeathPathWorldRewardRequest.newBuilder().build(), WorldProto.DeathPathWorldRewardResponse.class);
|
||||
WorldProto.DeathPathWorldRewardResponse rewardResponse = WorldHelper.sendMessageToWorldWithResult(0, WorldProto.DeathPathWorldRewardRequest.newBuilder().setGroupId(groupId).build(), WorldProto.DeathPathWorldRewardResponse.class);
|
||||
|
||||
if(rewardResponse==null){
|
||||
LOGGER.error("无排行信息");
|
||||
|
@ -590,7 +591,7 @@ public class DeathPathLogic {
|
|||
}
|
||||
for(WorldProto.GuildRank rank:rewardResponse.getRanksList()){
|
||||
int[] rewardByRank = getRewardByRank(rank.getRank());
|
||||
DeathChallengeCount reward = redisUtil.getObject(String.valueOf(rank.getGuildId()), DeathChallengeCount.class);
|
||||
DeathChallengeCount reward = redisUtil.getObject(serverId+":"+RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT+":"+String.valueOf(rank.getGuildId()), DeathChallengeCount.class);
|
||||
if(reward!=null&&reward.getUserReward().size()!=0){
|
||||
Map<Integer, DeathReward> userReward = reward.getUserReward();
|
||||
for(Map.Entry<Integer, DeathReward> rewardEntry:userReward.entrySet()){
|
||||
|
@ -613,7 +614,7 @@ public class DeathPathLogic {
|
|||
String[] removePersonKey = new String[personRankSet.size()];
|
||||
int index = 0;
|
||||
for(ZSetOperations.TypedTuple<String> item:guildRankSet){
|
||||
removeGuildKey[index] = RedisKey.getKey(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, item.getValue(),false);
|
||||
removeGuildKey[index] = RedisKey.getKey(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, item.getValue(),false);
|
||||
index++;
|
||||
}
|
||||
index = 0;
|
||||
|
@ -647,7 +648,7 @@ public class DeathPathLogic {
|
|||
|
||||
}
|
||||
|
||||
Cursor<String> cursor = RedisUtil.getInstence().scan(GameApplication.serverId+":DEATH_PATH*", -1);
|
||||
Cursor<String> cursor = RedisUtil.getInstence().scan(serverId +":DEATH_PATH*", -1);
|
||||
while (cursor.hasNext()) {
|
||||
//找到一次就添加一次
|
||||
String next = cursor.next();
|
||||
|
|
|
@ -40,7 +40,7 @@ public class DeathPathTotalGuildRank extends AbstractRank{
|
|||
|
||||
protected void getOptional(int index, ZSetOperations.TypedTuple<String> data, PlayerInfoProto.RankResponse.Builder builder) throws Exception {
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(Integer.parseInt(data.getValue()));
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(guildInfo.getId()), DeathChallengeCount.class);
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, String.valueOf(guildInfo.getId()), DeathChallengeCount.class);
|
||||
CommonProto.RankInfo.Builder everyRankInfo = CommonProto.RankInfo.newBuilder()
|
||||
.setRank(index)
|
||||
.setParam1(getParam1(data.getScore()))
|
||||
|
@ -56,7 +56,7 @@ public class DeathPathTotalGuildRank extends AbstractRank{
|
|||
@Override
|
||||
protected void getMyInfo(User user, String rkey, PlayerInfoProto.RankResponse.Builder allUserResponse) {
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PAHT_TOTAL_CHALLENGE_COUNT, String.valueOf(guildId), DeathChallengeCount.class);
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, String.valueOf(guildId), DeathChallengeCount.class);
|
||||
int myRank= RedisUtil.getInstence().getZSetreverseRank(redisKey,rkey,Integer.toString(guildId)).intValue();
|
||||
Double zSetScore = RedisUtil.getInstence().getZSetScore(redisKey, rkey, Integer.toString(guildId));
|
||||
CommonProto.RankInfo towerRankInfo = CommonProto.RankInfo.newBuilder()
|
||||
|
|
Loading…
Reference in New Issue