| | |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | /** |
| | | * 用户登录 |
| | | * @param currentLoggedUserKey |
| | | * @param username |
| | | */ |
| | | public void userLogin(String currentLoggedUserKey,String username) { |
| | | redisTemplate.opsForSet().add(currentLoggedUserKey, username); |
| | | } |
| | | |
| | | /** |
| | | * 用户登出 |
| | | * @param currentLoggedUserKey |
| | | * @param username |
| | | */ |
| | | public void userLogout(String currentLoggedUserKey,String username) { |
| | | redisTemplate.opsForSet().remove(currentLoggedUserKey, username); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前登录用户总人数 |
| | | * @param currentLoggedUserKey |
| | | * @return |
| | | */ |
| | | public long getCurrentLoggedUserCount(String currentLoggedUserKey) { |
| | | return redisTemplate.opsForSet().size(currentLoggedUserKey); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前登录用户的用户名列表 |
| | | * @param currentLoggedUserKey |
| | | * @return |
| | | */ |
| | | public Set<String> getCurrentLoggedUsers(String currentLoggedUserKey) { |
| | | return redisTemplate.opsForSet().members(currentLoggedUserKey); |
| | | } |
| | | |
| | | /** |
| | | * 基于Lua脚本实现原子查询并删除 |