redistemplate海量数据批量获取

 

 

 

multiGet
        // 前缀
        String prefix = "pois:";
        // 获取指定前缀的所有key
        Set keys = redisTemplate.keys(prefix.concat("*"));
        // 批量获取value
        List list = redisTemplate.opsForValue().multiGet(keys);

 

 

 

 

 

 

executePipelined
        // 前缀
        String prefix = "pois:";
        // 获取指定前缀的所有key
        Set keys = redisTemplate.keys(prefix.concat("*"));

        // 批量获取value
        List list = redisTemplate.executePipelined(new RedisCallback() {
            @Override
            public String doInRedis(RedisConnection connection) throws DataAccessException {
                for (String key : keys) {
                    connection.get(key.getBytes());
                }
                return null;
            }
        });

 

 

你可能感兴趣的:(redis,java)