redis管道pipeline

     Jedis jedis = new Jedis("127.0.0.1",6379);
        Pipeline pipeline = jedis.pipelined();
        for(int i = 0;i<1000;i++){
            String content = i + "";
            pipeline.set(content,content);
        }
        pipeline.sync();

  

Jedis jedis = new Jedis("127.0.0.1",6379);
Pipeline pipeline = jedis.pipelined();
Map<String, Response> responses = new LinkedHashMap<String, Response>();
        for(int i = 0;i<1000;i++){
            String content = i + "";
            Response<String> response = pipeline.get(content);
            responses.put(content,response);
        }
        pipeline.sync();
        for(String key:responses.keySet()){
            System.out.println("key:"+key + ",value:" + responses.get(key).get());
        }

  

猜你喜欢

转载自www.cnblogs.com/liaoyanglong/p/11711604.html