首页v2-定时任务-定时清理空麦位房间
This commit is contained in:
@@ -239,4 +239,27 @@ public class HomeV2Service {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void clearPartitionPoolSet(Integer partitionId){
|
||||
Set<Long> homeRoomSet = poolService.getPartitionMap(partitionId).readAllKeySet();
|
||||
if (CollectionUtils.isEmpty(homeRoomSet)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] uidArray = homeRoomSet.stream().map(Objects::toString).toArray(String[]::new);
|
||||
List<String> cacheList = jedisService.hmread(RedisKey.room_mic_up.getKey(), uidArray);
|
||||
if (CollectionUtils.isEmpty(cacheList)){
|
||||
poolService.getPartitionMap(partitionId).clear();
|
||||
return ;
|
||||
}
|
||||
|
||||
Set<Long> micRoomSet = cacheList.stream().map(Long::parseLong).collect(Collectors.toSet());
|
||||
homeRoomSet.removeAll(micRoomSet);
|
||||
if (CollectionUtils.isEmpty(homeRoomSet)){
|
||||
return;
|
||||
}
|
||||
|
||||
Long[] emptyRoomList = homeRoomSet.toArray(Long[]::new);
|
||||
poolService.getPartitionMap(partitionId).fastRemove(emptyRoomList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.accompany.scheduler.task;
|
||||
|
||||
import com.accompany.business.service.homeV2.HomeV2Service;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class HomeV2ListTask {
|
||||
|
||||
@Autowired
|
||||
private HomeV2Service homeV2Service;
|
||||
|
||||
/**
|
||||
* 缓存当前有效的表情JSON
|
||||
*/
|
||||
@Scheduled(cron = "0 */6 * * * ?")
|
||||
public void cacheFaceJson() {
|
||||
for (PartitionEnum partitionEnum : PartitionEnum.values()) {
|
||||
homeV2Service.clearPartitionPoolSet(partitionEnum.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user