Browse Source

网络教室

zouxuan 2 years ago
parent
commit
6bbdb87506

+ 2 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ImNetworkRoomServiceImpl.java

@@ -26,6 +26,7 @@ import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -187,7 +188,7 @@ public class ImNetworkRoomServiceImpl extends ServiceImpl<ImNetworkRoomDao, ImNe
         log.info("quitRoomSuccess: roomId={}, userId={}", roomId, userId);
         //防止幂等
         StringBuffer sb  = new StringBuffer(QUIT_ROOM_SUCCESS).append(roomId).append(userId);
-        if (!redisTemplate.opsForValue().setIfAbsent(sb.toString(),userId)){
+        if (!redisTemplate.opsForValue().setIfAbsent(sb.toString(),userId,1l, TimeUnit.SECONDS)){
             log.info("quitRoomSuccess break: roomId={}, userId={}", roomId, userId);
             return;
         }