UserInfoCacheServiceImpl implements UserInfoCacheService { @Override public Set<CIMUserInfo> onlineUser() { Set<CIMUserInfo> set = null ; Set<String> members = redisTemplate.opsForSet().members(LOGIN_STATUS_PREFIX); for (String member : members) { if (set == null){ set = new HashSet<>(64) ; } CIMUserInfo cimUserInfo = loadUserInfoByUserId(Long.valueOf(member)) ; set.add(cimUserInfo) ; } return set; }  @Override CIMUserInfo loadUserInfoByUserId(Long userId); @Override boolean saveAndCheckUserLoginStatus(Long userId); @Override void removeLoginStatus(Long userId); @Override Set<CIMUserInfo> onlineUser();  }
@Test public void onlineUser(){ Set<CIMUserInfo> cimUserInfos = userInfoCacheService.onlineUser(); LOGGER.info("cimUserInfos={}", JSON.toJSONString(cimUserInfos)); }