123333
This commit is contained in:
@@ -18,20 +18,35 @@ public class OnlineUserTodayCache {
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
private String getKey(LocalDateTime dateTime){
|
||||
private String getKey(LocalDate dateTime){
|
||||
String today = dateTime.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
return String.format(CacheConstants.ONLINE_TODAY_TOKEN_KEY,today);
|
||||
}
|
||||
|
||||
public boolean addOnlineUserId(Long userId, LocalDateTime dateTime){
|
||||
public boolean addOnlineUserId(Long userId, LocalDate dateTime){
|
||||
RSet<Long> set = redissonClient.getSet(getKey(dateTime));
|
||||
boolean res = set.add(userId);
|
||||
set.expire(Duration.ofDays(1));
|
||||
set.expire(Duration.ofDays(3));
|
||||
return res;
|
||||
}
|
||||
|
||||
public Set<Long> getAllOnlineToday(){
|
||||
RSet<Long> set = redissonClient.getSet(getKey(LocalDateTime.now()));
|
||||
RSet<Long> set = redissonClient.getSet(getKey(LocalDate.now()));
|
||||
return set.readAll();
|
||||
}
|
||||
|
||||
public Long getOnlineNum(LocalDate time){
|
||||
RSet<Long> set = redissonClient.getSet(getKey(time));
|
||||
return (long) set.size();
|
||||
}
|
||||
|
||||
public Long getOnlineTodayNum(){
|
||||
RSet<Long> set = redissonClient.getSet(getKey(LocalDate.now()));
|
||||
return (long) set.size();
|
||||
}
|
||||
|
||||
public Long getOnlineLastNum(){
|
||||
RSet<Long> set = redissonClient.getSet(getKey(LocalDate.now().plusDays(-1)));
|
||||
return (long) set.size();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user