十绝阵删除key
parent
393635b930
commit
987f4c6729
|
|
@ -204,6 +204,8 @@ public class RedisKey {
|
|||
public static final String DEATH_PATH_CHALLENGE_FIRST_PUSH = "DEATH_PATH_CHALLENGE_FIRST_PUSH";
|
||||
// 十绝阵挑战人数
|
||||
public static final String DEATH_PATH_TOTAL_CHALLENGE_COUNT = "DEATH_PATH_TOTAL_CHALLENGE_COUNT";
|
||||
public static final String DEATH_PATH_DELETE = "DEATH_PATH_DELETE";
|
||||
|
||||
|
||||
//问卷调查
|
||||
public static final String QUESTION_FROMBACK = "QUESTION_FROMBACK";
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.lang.reflect.Type;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class RedisUtil {
|
||||
|
|
@ -554,6 +555,29 @@ public class RedisUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 模糊删除key
|
||||
* @param key
|
||||
* @param pattern
|
||||
*/
|
||||
public void delVague(String key, String pattern){
|
||||
long start = System.currentTimeMillis();
|
||||
// 根据key获取要删除的key
|
||||
Set<String> removeSet = RedisUtil.getInstence().sGet(key);
|
||||
// 根据正则表达式去除不用删除的key
|
||||
removeSet.removeIf(v-> !Pattern.matches(pattern,v));
|
||||
// 转换数组
|
||||
String[] removeKeys = removeSet.toArray(new String[0]);
|
||||
long remove = 0;
|
||||
if (removeKeys != null && removeKeys.length > 0){
|
||||
// 删除key
|
||||
RedisUtil.getInstence().del(removeKeys);
|
||||
// 删除存储
|
||||
remove = RedisUtil.getInstence().setRemove(key, removeKeys);
|
||||
}
|
||||
LOGGER.info("模糊删除redisKey共耗时:{} ms,key数量:{} ,模糊key:{}",System.currentTimeMillis()-start,remove,key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据value从一个set中查询,是否存在
|
||||
*
|
||||
|
|
@ -1374,6 +1398,7 @@ public class RedisUtil {
|
|||
result = AreaManager.areaId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
|
||||
deathPathKeyHandler(result);
|
||||
helpHeroKeyHandler(result);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1382,8 +1407,8 @@ public class RedisUtil {
|
|||
* 十绝阵rediskey处理
|
||||
*/
|
||||
private void deathPathKeyHandler(String key){
|
||||
if(key.contains(RedisKey.HELP_FIGHT)){
|
||||
RedisUtil.getInstence().sSet(RedisKey.HELP_FIGHT_DELETE,key);
|
||||
if(key.contains(RedisKey.DEATH_PATH_DELETE)){
|
||||
RedisUtil.getInstence().sSet(RedisKey.DEATH_PATH_DELETE,key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -431,6 +431,8 @@ public class GlobalDataManaager implements IManager {
|
|||
FourChallengeLogic.getInstance().addFourChallengeNum(user,num);
|
||||
// 助战清理
|
||||
HelpHeroLogic.getInstance().clearHelpInfo(user);
|
||||
// 公会援助刷新
|
||||
GuildLogic.getInstance().everyDayFlushHelpLog(user);
|
||||
|
||||
// GuildChallengeLogic.getInstance().resetBossDamage(user);
|
||||
if(TimeUtils.isSpanTime(user.getPlayerInfoManager().getLoginTime(),TimeUtils.now(),1,0)){
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class GuilidManager {
|
|||
guildNameInfoMap.put(guildInfo.getName(),guildInfo);
|
||||
}
|
||||
|
||||
public static void removeGuildInfo(GuildInfo guildInfo) throws Exception {
|
||||
public static void removeGuildInfo(GuildInfo guildInfo){
|
||||
System.out.println("此处删除了工会信息"+guildInfo.getId());
|
||||
int guildId = guildInfo.getId();
|
||||
guildInfoMap.remove(guildId);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import java.math.BigDecimal;
|
|||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
|
|
@ -205,11 +206,10 @@ public class CrossDeathPathLogic {
|
|||
}
|
||||
RedisUtil.getInstence().hdel(RedisKey.DEATH_PATH_EVERY_OVER_HASH,String.valueOf(serverId));
|
||||
|
||||
Set<String> dimKey = RedisUtil.getInstence().getDimKey("DEATH_PATH*" + groupId + ":*", -1);
|
||||
for (String key : dimKey) {
|
||||
LOGGER.info("=================删除跨服十绝阵排行:{}", key);
|
||||
RedisUtil.getInstence().del(key);
|
||||
}
|
||||
// 删除rediskey
|
||||
String pattern = "DEATH_PATH.*."+groupId+":.*";
|
||||
RedisUtil.getInstence().delVague(RedisKey.DEATH_PATH_DELETE,pattern);
|
||||
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import util.TimeUtils;
|
|||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
|
|
@ -303,9 +304,7 @@ public class DeathPathLogic {
|
|||
*/
|
||||
public void getBaseInfo(ISession session,MessageTypeProto.MessageType messageType){
|
||||
int uid = session.getUid();
|
||||
String type = GameApplication.serverProperties.getId() + RedisKey.Delimiter_colon + RedisKey.DEATH_PATH_CHALLENGE_COUNT;
|
||||
String changeString = RedisUtil.getInstence().getKey(type,String.valueOf(uid),false);
|
||||
String count = (String) RedisUtil.getInstence().get(changeString);
|
||||
String count = RedisUtil.getInstence().get(RedisKey.DEATH_PATH_CHALLENGE_COUNT,String.valueOf(uid),String.class);
|
||||
int challengeCount = count==null?0:Integer.parseInt(count);
|
||||
// 结束时间和挑战次数
|
||||
Family.GetDeathPathInfoResponse.Builder response = Family.GetDeathPathInfoResponse.newBuilder()
|
||||
|
|
@ -350,8 +349,7 @@ public class DeathPathLogic {
|
|||
*/
|
||||
public void challenge(ISession session, int pathId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
String changeStringKey = GameApplication.serverProperties.getId() + RedisKey.Delimiter_colon + RedisKey.DEATH_PATH_CHALLENGE_COUNT + RedisKey.Delimiter_colon + String.valueOf(uid);
|
||||
String count = (String) RedisUtil.getInstence().get(changeStringKey);
|
||||
String count = RedisUtil.getInstence().get(RedisKey.DEATH_PATH_CHALLENGE_COUNT,String.valueOf(uid),String.class);
|
||||
if(!StringUtil.isEmpty(count)&&Integer.parseInt(count)>=SGuildSetting.sGuildSetting.getChallengeMaxTime()){
|
||||
throw new ErrorCodeException(ErrorCode.REFRESH_WHEL_TIME_NOT);
|
||||
}
|
||||
|
|
@ -379,7 +377,7 @@ public class DeathPathLogic {
|
|||
//更新排行榜数据
|
||||
tasks.offer(new DeathPathTask(uid,guildId,damage,pathId,getGroupId()));
|
||||
//挑战次数记录
|
||||
RedisUtil.getInstence().increment(changeStringKey);
|
||||
RedisUtil.getInstence().increment(RedisUtil.getInstence().getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT,String.valueOf(uid)));
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
|
||||
// 跨服十绝阵添加
|
||||
|
|
@ -646,8 +644,10 @@ public class DeathPathLogic {
|
|||
int[] rewardByRank = getRewardByRank(entry.getKey());
|
||||
deathPathSendMail(reward,rewardByRank);
|
||||
}
|
||||
Set<String> keys = RedisUtil.getInstence().getDimKey(serverId + ":DEATH_PATH*", -1);
|
||||
keys.forEach(key-> RedisUtil.getInstence().del(key));
|
||||
|
||||
// 删除rediskey
|
||||
String pattern = serverId+":DEATH_PATH.*";
|
||||
RedisUtil.getInstence().delVague(RedisKey.DEATH_PATH_DELETE,pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -54,9 +54,6 @@ public class GuildLogic {
|
|||
|
||||
public void flushEveryDay(User user, PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder)throws Exception {
|
||||
takeAllReward(user);
|
||||
// 发送公会援助奖励
|
||||
// sendGuildHelpRewardEmail(user);
|
||||
|
||||
user.getGuildMyInfo().setFetetype(0);
|
||||
user.getGuildMyInfo().clearHadTakeReward();
|
||||
user.getGuildMyInfo().setGuildChallengeDamage(0);
|
||||
|
|
@ -65,8 +62,6 @@ public class GuildLogic {
|
|||
fBuilder.setLastFeteType(user.getGuildMyInfo().getFetetype());
|
||||
fBuilder.addAllTakeFeteReward(new HashSet<>());
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1669,6 +1664,26 @@ public class GuildLogic {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 每天刷新公会援助
|
||||
* @param user
|
||||
*/
|
||||
public void everyDayFlushHelpLog(User user){
|
||||
try {
|
||||
GuildLogic.sendGuildHelpRewardEmail(user);
|
||||
GuildMyInfo guildMyInfo = user.getGuildMyInfo();
|
||||
guildMyInfo.setGuidHelpInfo(new HashMap<>());
|
||||
guildMyInfo.setGuidHelpHadTakeInfo(new HashMap<>());
|
||||
guildMyInfo.setGuildHelpSendTime(0);
|
||||
guildMyInfo.setGuildHelpReward(false);
|
||||
guildMyInfo.setGuildHelpTime(0);
|
||||
LOGGER.info("公会援助刷新uid=>{}",user.getId());
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("公会援助报错uid=>{}",user.getId());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//sendGuildHelpRewardEmail
|
||||
public static void sendGuildHelpRewardEmail(User user)throws Exception{
|
||||
// 补发奖励
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import manager.STableManager;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.CommonProto;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -331,10 +330,12 @@ public class HelpHeroLogic {
|
|||
* 零点清理redis数据
|
||||
*/
|
||||
public void zeroClearRedisHelp(){
|
||||
Set<String> set = RedisUtil.getInstence().sGet(RedisKey.HELP_FIGHT_DELETE);
|
||||
String[] keys = set.toArray(new String[0]);
|
||||
RedisUtil.getInstence().del(keys);
|
||||
RedisUtil.getInstence().setRemove(RedisKey.HELP_FIGHT_DELETE,keys);
|
||||
// 不是零点
|
||||
if (TimeUtils.getHourOfDay() != 0 || TimeUtils.getMiunte() != 0){
|
||||
return;
|
||||
}
|
||||
String pattern = GameApplication.serverId +":" + RedisKey.HELP_FIGHT + ".*";
|
||||
RedisUtil.getInstence().delVague(RedisKey.HELP_FIGHT_DELETE,pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -201,12 +201,11 @@ public class MinuteTask extends Thread {
|
|||
}
|
||||
|
||||
//每日凌晨零点执行
|
||||
public void everyZeroTask() throws Exception {
|
||||
private void everyZeroTask(){
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
if(hour == 0 && minute ==0){
|
||||
|
||||
//保证每分钟线程
|
||||
try {
|
||||
GlobleSystemLogic.getInstence().calCulRank();
|
||||
|
|
@ -216,52 +215,15 @@ public class MinuteTask extends Thread {
|
|||
RedisUtil.getInstence().del(RedisKey.getKey(RedisKey.GUILD_RED_PACKAGE_RANK,String.valueOf(guildInfoEntry.getKey()),false));
|
||||
guildInfoEntry.getValue().reSetFete();
|
||||
LOGGER.info("{}更新公会祭祀完毕",guildInfoEntry.getValue().getName());
|
||||
// SimpleTransaction transaction = SimpleTransaction.current();
|
||||
GuildInfo guildInfo = guildInfoEntry.getValue();
|
||||
Set<Integer> sendUids = new HashSet<>();
|
||||
for (Set<Integer> items : guildInfo.getMembers().values()) {
|
||||
sendUids.addAll(items);
|
||||
}
|
||||
// Lockeys.getLockeys().lock("guild",sendUids);
|
||||
// 公会援助日志
|
||||
guildInfo.clearGuildHelpLog();
|
||||
for (Integer sendUid : sendUids) {
|
||||
User target = UserManager.getUser(sendUid);
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(target, true, user -> {
|
||||
GuildLogic.sendGuildHelpRewardEmail(target);
|
||||
GuildMyInfo guildMyInfo = target.getGuildMyInfo();
|
||||
guildMyInfo.setGuidHelpInfo(new HashMap<>());
|
||||
guildMyInfo.setGuidHelpHadTakeInfo(new HashMap<>());
|
||||
guildMyInfo.setGuildHelpSendTime(0);
|
||||
guildMyInfo.setGuildHelpReward(false);
|
||||
guildMyInfo.setGuildHelpTime(0);
|
||||
LOGGER.info("公会援助刷新uid=>{}",sendUid);
|
||||
});
|
||||
ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker);
|
||||
}
|
||||
// LOGGER.info("{}更新公会援助完毕",guildInfoEntry.getValue().getName());
|
||||
|
||||
// //统一清除
|
||||
// for (Integer sendUid : sendUids) {
|
||||
// User target = UserManager.getUser(sendUid);
|
||||
// GuildLogic.sendGuildHelpRewardEmail(target);
|
||||
// GuildMyInfo guildMyInfo = target.getGuildMyInfo();
|
||||
// guildMyInfo.setGuidHelpInfo(new HashMap<>());
|
||||
// guildMyInfo.setGuidHelpHadTakeInfo(new HashMap<>());
|
||||
// guildMyInfo.setGuildHelpSendTime(0);
|
||||
// guildMyInfo.setGuildHelpReward(false);
|
||||
// guildMyInfo.setGuildHelpTime(0);
|
||||
// }
|
||||
|
||||
// SimpleTransaction.remove();
|
||||
//处理公会援助信息
|
||||
|
||||
//入库
|
||||
MongoUtil.getInstence().lastUpdate();
|
||||
}
|
||||
}catch (Exception e){
|
||||
LOGGER.error("Exception everyFiveTask,{}",e.getMessage());
|
||||
}
|
||||
|
||||
LOGGER.info("DailyOfFiveTask start ...");
|
||||
GlobalDataManaager.everTask(0);
|
||||
ThreadManager.commitGeneralTask(new GuildCheckOfflineTask());
|
||||
|
|
|
|||
Loading…
Reference in New Issue