/**
     * key模糊查找
     *
     * @param keys 要查找的key 例: aaa* ,aaa开头的所有key
     * @return 匹配到的key集合
     */
    public Set<String> keys(String keys) {
        TreeSet<String> set = new TreeSet<>();
        try (Jedis jedis = getJedis()) {
            String cursor = ScanParams.SCAN_POINTER_START;
            ScanParams scanParams = new ScanParams().match(keys).count(10000);
            do {
                ScanResult<String> scan = jedis.scan(cursor, scanParams);
                set.addAll(scan.getResult());
                cursor = scan.getCursor();
            } while (!ScanParams.SCAN_POINTER_START.equals(cursor));
        } catch (Exception e) {
            log.error(e);
        }
        return set;
    }

 

相关文章:

  • 2022-12-23
  • 2021-07-18
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2021-08-10
猜你喜欢
  • 2022-12-23
  • 2021-10-22
  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案