From 27ac3039b61e6f8413db7d4dcc0ece0d9c21e5cf Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 15 Sep 2025 18:22:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=EF=BC=8C=E9=80=80=E5=87=BA?= =?UTF-8?q?=E6=88=BF=E9=97=B4=E7=A7=BB=E9=99=A4=E6=88=BF=E9=97=B4=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../live/app/command/user/LiveQuitRoomExe.java | 14 ++++++++++++++ .../other/app/command/room/RoomEnterCmdExe.java | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/rc-service/rc-service-live/live-application/src/main/java/com/red/circle/live/app/command/user/LiveQuitRoomExe.java b/rc-service/rc-service-live/live-application/src/main/java/com/red/circle/live/app/command/user/LiveQuitRoomExe.java index 4f8384b1..d75ad23c 100644 --- a/rc-service/rc-service-live/live-application/src/main/java/com/red/circle/live/app/command/user/LiveQuitRoomExe.java +++ b/rc-service/rc-service-live/live-application/src/main/java/com/red/circle/live/app/command/user/LiveQuitRoomExe.java @@ -1,11 +1,13 @@ package com.red.circle.live.app.command.user; import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd; +import com.red.circle.component.redis.service.RedisService; import com.red.circle.live.domain.gateway.LiveMicrophoneGateway; import com.red.circle.live.domain.live.LiveMicrophone; import com.red.circle.live.domain.live.LiveMusicStatus; import com.red.circle.live.infra.database.cache.service.LiveMicCacheService; import com.red.circle.live.infra.database.cache.service.LiveMusicHeartbeatService; +import com.red.circle.other.inner.endpoint.user.region.UserRegionClient; import com.red.circle.tool.core.collection.CollectionUtils; import java.util.List; import java.util.Objects; @@ -24,6 +26,8 @@ public class LiveQuitRoomExe { private final LiveMicCacheService liveMicCacheService; private final LiveMicrophoneGateway liveMicrophoneGateway; private final LiveMusicHeartbeatService liveMusicHeartbeatService; + private final UserRegionClient userRegionClient; + private final RedisService redisService; public void execute(AppRoomIdCmd cmd) { // 移除在线用户 @@ -50,6 +54,16 @@ public class LiveQuitRoomExe { && Objects.equals(musicStatus.getUserId(), cmd.requiredReqUserId())) { liveMusicHeartbeatService.removeMickUser(cmd.getRoomId()); } + + try { + //清空房间列表缓存 + String region = userRegionClient.getRegionCode(cmd.requiredReqUserId()).getBody(); + String key = cmd.requireReqSysOrigin() + region; + redisService.delete("USER:REGION_ROOM:" + key); + } catch (Exception e) { + // ignore + } + } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java index 1be9e223..930e080b 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomEnterCmdExe.java @@ -19,6 +19,7 @@ import com.red.circle.other.app.dto.cmd.room.RoomEntryCmd; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; import com.red.circle.other.infra.database.cache.service.other.RoomManagerCacheService; +import com.red.circle.other.infra.database.cache.service.user.RegionRoomCacheService; import com.red.circle.other.infra.database.cache.service.user.UserAgoraTokenCacheService; import com.red.circle.other.infra.database.mongo.entity.live.RoomProfile; import com.red.circle.other.infra.database.mongo.entity.live.RoomProfileManager; @@ -81,6 +82,7 @@ public class RoomEnterCmdExe { private final TrtcClient trtcClient; private final UserAgoraTokenCacheService userAgoraTokenCacheService; private final TaskMqMessage taskMqMessage; + private final RegionRoomCacheService regionRoomCacheService; public EntryRoomResponseCO execute(RoomEntryCmd cmd) { //checkEntryUserId(cmd); @@ -124,6 +126,11 @@ public class RoomEnterCmdExe { log.error("进房间添加足迹异常:{}", e.getMessage()); } + //清空房间列表缓存 + String region = userRegionGateway.getRegionCode(cmd.requiredReqUserId()); + String key = cmd.requireReqSysOrigin() + region; + regionRoomCacheService.remove(key); + return new EntryRoomResponseCO() .setRoomProfile( new EntryRoomProfileCO()