From d5129475d506572d9b6ab70a713e4004d8da54b6 Mon Sep 17 00:00:00 2001 From: grimm <1769111741@qq.com> Date: Fri, 21 Jun 2024 11:26:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=83=AD=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/c_database_version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/c_database_version.json b/conf/c_database_version.json index cf6773531..6ef938c48 100644 --- a/conf/c_database_version.json +++ b/conf/c_database_version.json @@ -1,4 +1,4 @@ { "version":"11", - "tables":"GlobalActivity|Train|GlobalSystemConfig|FaxiangConfig|ItemConfig|BlessingRewardPoolNew" + "tables":"GlobalActivity" } \ No newline at end of file From 5835a4361827268ea595246ee89ff9315484294c Mon Sep 17 00:00:00 2001 From: grimm <1769111741@qq.com> Date: Tue, 25 Jun 2024 14:52:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B6=88=E6=81=AFbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jieling/chat/messge/MessageCache.java | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/chat/messge/MessageCache.java b/serverlogic/src/main/java/com/ljsd/jieling/chat/messge/MessageCache.java index 5ce3a4a14..b986fc791 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/chat/messge/MessageCache.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/chat/messge/MessageCache.java @@ -39,41 +39,53 @@ public class MessageCache { RedisUtil.getInstence().hset(key,String.valueOf(index),gson.toJson(chatInfo)); } - public static List getCrossMsg(long messageId, String group) { - String key = RedisKey.CHAT_CROSS_INFO_CACHE + group; - Map rawMap = RedisUtil.getInstence().hmget(key); - - if (rawMap == null || rawMap.isEmpty()) { - return Collections.emptyList(); - } + public static List getCrossMsg(long messageId,String group){ + String key = RedisKey.CHAT_CROSS_INFO_CACHE+group; + Map map = new HashMap<>(); + Map collect = RedisUtil.getInstence().hmget(key); + collect.entrySet().forEach(o -> map.put(Integer.parseInt(o.getKey().toString()), + gson.fromJson(o.getValue().toString(),ChatProto.ChatInfo.class))); List objs = new ArrayList<>(); Object obj = RedisUtil.getInstence().get(RedisKey.CHAT_CROSS_MSG_ID + group); - - if (obj == null) { + if(obj==null){ return objs; } int writeIndex = Integer.parseInt(String.valueOf(obj)); - int nextIndex = writeIndex % capuatiy; // Assuming capacity is a static value or defined elsewhere + Integer nextIndex = writeIndex%capuatiy; + + if(nextIndex==-1){ + nextIndex = capuatiy - 1; + } + if(collect.size()<=0){ + return objs; + } boolean needCompareTime = (messageId == 0); - while (rawMap.containsKey(nextIndex)) { - String rawValue = String.valueOf(rawMap.get(nextIndex)); - ChatProto.ChatInfo chatInfo = gson.fromJson(rawValue, ChatProto.ChatInfo.class); + while(map.containsKey(nextIndex)){ - if (!needCompareTime && messageId >= chatInfo.getMessageId()) { + ChatProto.ChatInfo o = map.get(nextIndex); + if(!needCompareTime){ + //比较消息id + if(messageId>=o.getMessageId()){ + break; + } + + } + objs.add(0, o); + if(objs.size()>perCaught){ break; } - - objs.add(0, chatInfo); - - if (objs.size() > perCaught) { - break; + nextIndex--; + if(nextIndex == -1){ + nextIndex = capuatiy - 1; } - - nextIndex = (nextIndex - 1 + capuatiy) % capuatiy; } - return objs.size() > perCaught ? objs.subList(0, perCaught) : objs; + if(!needCompareTime && objs.size()>perCaught){ + return objs.subList(0,perCaught); + } + + return objs; } }