Package redis.clients.jedis

Examples of redis.clients.jedis.Pipeline


  assertEquals(r.get(), "bar");
    }

    @Test
    public void multi() {
  Pipeline p = jedis.pipelined();
  p.multi();
  Response<Long> r1 = p.hincrBy("a", "f1", -1);
  Response<Long> r2 = p.hincrBy("a", "f1", -2);
  Response<List<Object>> r3 = p.exec();
  List<Object> result = p.syncAndReturnAll();

  assertEquals(new Long(-1), r1.get());
  assertEquals(new Long(-3), r2.get());

  assertEquals(4, result.size());
View Full Code Here


    @Test
    public void multiWithSync() {
  jedis.set("foo", "314");
  jedis.set("bar", "foo");
  jedis.set("hello", "world");
  Pipeline p = jedis.pipelined();
  Response<String> r1 = p.get("bar");
  p.multi();
  Response<String> r2 = p.get("foo");
  p.exec();
  Response<String> r3 = p.get("hello");
  p.sync();

  // before multi
  assertEquals("foo", r1.get());
  // It should be readable whether exec's response was built or not
  assertEquals("314", r2.get());
View Full Code Here

  assertEquals("world", r3.get());
    }

    @Test(expected = JedisDataException.class)
    public void pipelineExecShoudThrowJedisDataExceptionWhenNotInMulti() {
  Pipeline pipeline = jedis.pipelined();
  pipeline.exec();
    }
View Full Code Here

  pipeline.exec();
    }

    @Test(expected = JedisDataException.class)
    public void pipelineDiscardShoudThrowJedisDataExceptionWhenNotInMulti() {
  Pipeline pipeline = jedis.pipelined();
  pipeline.discard();
    }
View Full Code Here

  pipeline.discard();
    }

    @Test(expected = JedisDataException.class)
    public void pipelineMultiShoudThrowJedisDataExceptionWhenAlreadyInMulti() {
  Pipeline pipeline = jedis.pipelined();
  pipeline.multi();
  pipeline.set("foo", "3");
  pipeline.multi();
    }
View Full Code Here

  pipeline.multi();
    }

    @Test
    public void testDiscardInPipeline() {
  Pipeline pipeline = jedis.pipelined();
  pipeline.multi();
  pipeline.set("foo", "bar");
  Response<String> discard = pipeline.discard();
  Response<String> get = pipeline.get("foo");
  pipeline.sync();
  discard.get();
  get.get();
    }
View Full Code Here

    @Test
    public void testEval() {
  String script = "return 'success!'";

  Pipeline p = jedis.pipelined();
  Response<String> result = p.eval(script);
  p.sync();

  assertEquals("success!", result.get());
    }
View Full Code Here

    public void testEvalKeyAndArg() {
  String key = "test";
  String arg = "3";
  String script = "redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])";

  Pipeline p = jedis.pipelined();
  p.set(key, "0");
  Response<String> result0 = p.eval(script, Arrays.asList(key),
    Arrays.asList(arg));
  p.incr(key);
  Response<String> result1 = p.eval(script, Arrays.asList(key),
    Arrays.asList(arg));
  Response<String> result2 = p.get(key);
  p.sync();

  assertNull(result0.get());
  assertNull(result1.get());
  assertEquals("13", result2.get());
    }
View Full Code Here

  String script = "return 'success!'";
  String sha1 = jedis.scriptLoad(script);

  assertTrue(jedis.scriptExists(sha1));

  Pipeline p = jedis.pipelined();
  Response<String> result = p.evalsha(sha1);
  p.sync();

  assertEquals("success!", result.get());
    }
View Full Code Here

  String script = "redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])";
  String sha1 = jedis.scriptLoad(script);

  assertTrue(jedis.scriptExists(sha1));

  Pipeline p = jedis.pipelined();
  p.set(key, "0");
  Response<String> result0 = p.evalsha(sha1, Arrays.asList(key),
    Arrays.asList(arg));
  p.incr(key);
  Response<String> result1 = p.evalsha(sha1, Arrays.asList(key),
    Arrays.asList(arg));
  Response<String> result2 = p.get(key);
  p.sync();

  assertNull(result0.get());
  assertNull(result1.get());
  assertEquals("13", result2.get());
    }
View Full Code Here

TOP

Related Classes of redis.clients.jedis.Pipeline

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.