瀏覽代碼

延长redis数据过期时间

779513719 5 年之前
父節點
當前提交
a6088838b1
共有 1 個文件被更改,包括 6 次插入8 次删除
  1. 6 8
      server-chat/src/main/java/com/cn/processor/IMChatAsyncChatMessageProcessor.java

+ 6 - 8
server-chat/src/main/java/com/cn/processor/IMChatAsyncChatMessageProcessor.java

@@ -92,21 +92,19 @@ public class IMChatAsyncChatMessageProcessor extends DefaultAsyncChatMessageProc
      * @date 2020/2/18 21:02
      */
     private void extendRedisData(ChatBody chatBody, ChannelContext channelContext){
-        String userId = chatBody.getFrom();
-        String groupId = chatBody.getGroup_id();
         ImSessionContext imSessionContext = (ImSessionContext)channelContext.getAttribute();
         Client client = imSessionContext.getClient();
         if(client != null) {
             User onlineUser = client.getUser();
             if(onlineUser != null){
-                userCache.expire(userId + SUBFIX + TERMINAL + SUBFIX + onlineUser.getTerminal(),TIME_OUT);
+                userCache.expire(chatBody.getFrom() + SUBFIX + TERMINAL + SUBFIX + onlineUser.getTerminal(),TIME_OUT);
             }
         }
-        userCache.expire( userId + SUBFIX + GROUP,TIME_OUT);
-        userCache.expire(userId + SUBFIX + INFO,TIME_OUT);
-        userCache.expire(userId + SUBFIX + FRIENDS,TIME_OUT);
-        groupCache.expire(groupId + SUBFIX + USER,TIME_OUT);
-        groupCache.expire(groupId + SUBFIX + INFO,TIME_OUT);
+        userCache.expire( chatBody.getFrom() + SUBFIX + GROUP,TIME_OUT);
+        userCache.expire(chatBody.getFrom() + SUBFIX + INFO,TIME_OUT);
+        userCache.expire(chatBody.getFrom() + SUBFIX + FRIENDS,TIME_OUT);
+        groupCache.expire(chatBody.getGroup_id() + SUBFIX + USER,TIME_OUT);
+        groupCache.expire(chatBody.getGroup_id() + SUBFIX + INFO,TIME_OUT);
     }
 
     /**