redis集群(jedis)批量删除同一前缀
2017-03-25 14:44 小诩 阅读(2940) 评论(0) 编辑 收藏 举报public Set<String> getByPrefix(String key) { Set<String> setResult = new HashSet<>(); try { ShardedJedis jedis = redisDataSource.getJedisClient(); Iterator<Jedis> jedisIterator = jedis.getAllShards().iterator(); while(jedisIterator.hasNext()){ setResult = jedisIterator.next().keys(key+"*"); } } catch (Exception e) { logger.error(e.getMessage(), e); } return setResult; }