redis集群(jedis)批量删除同一前缀

public Set getByPrefix(String key) {
        Set setResult = new HashSet<>();
        try {
            ShardedJedis jedis  = redisDataSource.getJedisClient();
            Iterator jedisIterator = jedis.getAllShards().iterator();
            while(jedisIterator.hasNext()){
                setResult = jedisIterator.next().keys(key+"*");
            }
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return setResult;
    }

 

转载于:https://www.cnblogs.com/gaoxufei/p/6617140.html

你可能感兴趣的:(redis集群(jedis)批量删除同一前缀)