ludc
2024-09-26 085df90e488067783759dcd63cdb5fb43a51ff1f
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisService.java
@@ -390,6 +390,41 @@
        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脚本实现原子查询并删除