@Test public void getKeys(){ System.out.print("---------------"+redisUtil); Set<String> set =redisUtil.getKeys("thoth:spirit:*"); System.out.print("---------------"); for (String str:set){ System.out.print("--------str:"+str); } }
public Set<String> getKeys(String pattern) { Map<String, JedisPool> clusterNodes = jedisCluster.getClusterNodes(); TreeSet<String> keys = new TreeSet<String>(); for (String k : clusterNodes.keySet()) { logger.debug("Getting keys from: {}", k); JedisPool jp = clusterNodes.get(k); Jedis connection = jp.getResource(); try { int cursor = 0; do { ScanResult<String> scanResult = connection.scan("" + cursor, new ScanParams().match(pattern)); if (scanResult.getResult().size() > 0) { for (String key : scanResult.getResult()) { keys.add(key); } } cursor = Integer.valueOf(new String(scanResult.getCursorAsBytes())); } while (cursor > 0); } catch (Exception e) { logger.error("Getting keys error: {}", e); } finally { logger.debug("Connection closed."); if (connection != null) { connection.close(); } } } logger.debug("------------->keys=" + keys.toString()); return keys; }
RedisUtil { public Set<String> getKeys(String pattern) { Map<String, JedisPool> clusterNodes = jedisCluster.getClusterNodes(); TreeSet<String> keys = new TreeSet<String>(); for (String k : clusterNodes.keySet()) { logger.debug("Getting keys from: {}", k); JedisPool jp = clusterNodes.get(k); Jedis connection = jp.getResource(); try { int cursor = 0; do { ScanResult<String> scanResult = connection.scan("" + cursor, new ScanParams().match(pattern)); if (scanResult.getResult().size() > 0) { for (String key : scanResult.getResult()) { keys.add(key); } } cursor = Integer.valueOf(new String(scanResult.getCursorAsBytes())); } while (cursor > 0); } catch (Exception e) { logger.error("Getting keys error: {}", e); } finally { logger.debug("Connection closed."); if (connection != null) { connection.close(); } } } logger.debug("------------->keys=" + keys.toString()); return keys; } }
RedisUtil { public Set<String> getKeys(String pattern) { Map<String, JedisPool> clusterNodes = jedisCluster.getClusterNodes(); TreeSet<String> keys = new TreeSet<String>(); for (String k : clusterNodes.keySet()) { logger.debug("Getting keys from: {}", k); JedisPool jp = clusterNodes.get(k); Jedis connection = jp.getResource(); try { int cursor = 0; do { ScanResult<String> scanResult = connection.scan("" + cursor, new ScanParams().match(pattern)); if (scanResult.getResult().size() > 0) { for (String key : scanResult.getResult()) { keys.add(key); } } cursor = Integer.valueOf(new String(scanResult.getCursorAsBytes())); } while (cursor > 0); } catch (Exception e) { logger.error("Getting keys error: {}", e); } finally { logger.debug("Connection closed."); if (connection != null) { connection.close(); } } } logger.debug("------------->keys=" + keys.toString()); return keys; }  }
RedisUtil { public Set<String> getKeys(String pattern) { Map<String, JedisPool> clusterNodes = jedisCluster.getClusterNodes(); TreeSet<String> keys = new TreeSet<String>(); for (String k : clusterNodes.keySet()) { logger.debug("Getting keys from: {}", k); JedisPool jp = clusterNodes.get(k); Jedis connection = jp.getResource(); try { int cursor = 0; do { ScanResult<String> scanResult = connection.scan("" + cursor, new ScanParams().match(pattern)); if (scanResult.getResult().size() > 0) { for (String key : scanResult.getResult()) { keys.add(key); } } cursor = Integer.valueOf(new String(scanResult.getCursorAsBytes())); } while (cursor > 0); } catch (Exception e) { logger.error("Getting keys error: {}", e); } finally { logger.debug("Connection closed."); if (connection != null) { connection.close(); } } } logger.debug("------------->keys=" + keys.toString()); return keys; }  Set<String> getKeys(String pattern); static Set<Long> convertStringSet2LongSet(Set<String> strSet); static int randomSuperTinyExpireSecs(); static int randomTinyExpireSecs(); static int randomSmallExpireSecs(); static int randomMediumExpireSecs(); static int randomLargeExpireSecs(); }
RedisUtil { public Set<String> getKeys(String pattern) { Map<String, JedisPool> clusterNodes = jedisCluster.getClusterNodes(); TreeSet<String> keys = new TreeSet<String>(); for (String k : clusterNodes.keySet()) { logger.debug("Getting keys from: {}", k); JedisPool jp = clusterNodes.get(k); Jedis connection = jp.getResource(); try { int cursor = 0; do { ScanResult<String> scanResult = connection.scan("" + cursor, new ScanParams().match(pattern)); if (scanResult.getResult().size() > 0) { for (String key : scanResult.getResult()) { keys.add(key); } } cursor = Integer.valueOf(new String(scanResult.getCursorAsBytes())); } while (cursor > 0); } catch (Exception e) { logger.error("Getting keys error: {}", e); } finally { logger.debug("Connection closed."); if (connection != null) { connection.close(); } } } logger.debug("------------->keys=" + keys.toString()); return keys; }  Set<String> getKeys(String pattern); static Set<Long> convertStringSet2LongSet(Set<String> strSet); static int randomSuperTinyExpireSecs(); static int randomTinyExpireSecs(); static int randomSmallExpireSecs(); static int randomMediumExpireSecs(); static int randomLargeExpireSecs();  }