标签:set 使用 sorted connected data pipeline 延迟 精度 命令
public void pipeLine() { Jedis jedis = null; try { jedis = new Jedis(REDIS_HOST, REDIS_PORT); Pipeline pipeline = jedis.pipelined(); for (int i = 0; i < COUNT; i++) { pipeline.incr(testKey); } pipeline.sync(); } catch (Exception e) { e.printStackTrace(); } finally { if(jedis != null) jedis.disconnect(); } } public void withoutPipeline() { Jedis jedis = null; try { jedis = new Jedis(REDIS_HOST, REDIS_PORT); for (int i = 0; i < COUNT; i++) { jedis.incr(testKey); } } catch (Exception e) { e.printStackTrace(); } finally { if (jedis != null) jedis.disconnect(); } } public static void main(String[] args) { PipelineTest pipelineTest = new PipelineTest(); long start = System.currentTimeMillis(); pipelineTest.withoutPipeline(); long mid = System.currentTimeMillis(); System.out.println("Without pipeline, using: " + (mid - start)); pipelineTest.pipeLine(); System.out.println("With pipeline, using: " + (System.currentTimeMillis() - mid)); }
Without pipeline, using: 9816 With pipeline, using: 45
标签:set 使用 sorted connected data pipeline 延迟 精度 命令
原文地址:http://www.cnblogs.com/wttttt/p/7091647.html