Package redis.clients.jedis

Examples of redis.clients.jedis.Transaction.exec()


  trans.sadd("foo", "a");
  trans.sadd("foo", "b");
  trans.scard("foo");

  List<Object> response = trans.exec();

  List<Object> expected = new ArrayList<Object>();
  expected.add(1L);
  expected.add(1L);
  expected.add(2L);
View Full Code Here


  trans.sadd(bfoo, ba);
  trans.sadd(bfoo, bb);
  trans.scard(bfoo);

  response = trans.exec();

  expected = new ArrayList<Object>();
  expected.add(1L);
  expected.add(1L);
  expected.add(2L);
View Full Code Here

  nj.auth("foobared");
  nj.set("mykey", "bar");
  nj.disconnect();

  t.set("mykey", "foo");
  List<Object> resp = t.exec();
  assertEquals(null, resp);
  assertEquals("bar", jedis.get("mykey"));

  // Binary
  jedis.watch(bmykey, "foobar".getBytes());
View Full Code Here

  nj.auth("foobared");
  nj.set(bmykey, bbar);
  nj.disconnect();

  t.set(bmykey, bfoo);
  resp = t.exec();
  assertEquals(null, resp);
  assertTrue(Arrays.equals(bbar, jedis.get(bmykey)));
    }

    @Test
View Full Code Here

  nj.auth("foobared");
  nj.set("mykey", "bar");
  nj.disconnect();

  t.set("mykey", val);
  List<Object> resp = t.exec();
  assertEquals(1, resp.size());
  assertEquals("OK", resp.get(0));

  // Binary
  jedis.watch(bmykey);
View Full Code Here

  nj.auth("foobared");
  nj.set(bmykey, bbar);
  nj.disconnect();

  t.set(bmykey, bval);
  resp = t.exec();
  assertEquals(1, resp.size());
  assertEquals("OK", resp.get(0));
    }

    @Test(expected = JedisDataException.class)
View Full Code Here

  Response<String> string = t.get("string");
  Response<String> list = t.lpop("list");
  Response<String> hash = t.hget("hash", "foo");
  Response<Set<String>> zset = t.zrange("zset", 0, -1);
  Response<String> set = t.spop("set");
  t.exec();

  assertEquals("foo", string.get());
  assertEquals("foo", list.get());
  assertEquals("bar", hash.get());
  assertEquals("foo", zset.get().iterator().next());
View Full Code Here

  Response<byte[]> string = t.get("string".getBytes());
  Response<byte[]> list = t.lpop("list".getBytes());
  Response<byte[]> hash = t.hget("hash".getBytes(), "foo".getBytes());
  Response<Set<byte[]>> zset = t.zrange("zset".getBytes(), 0, -1);
  Response<byte[]> set = t.spop("set".getBytes());
  t.exec();

  assertArrayEquals("foo".getBytes(), string.get());
  assertArrayEquals("foo".getBytes(), list.get());
  assertArrayEquals("bar".getBytes(), hash.get());
  assertArrayEquals("foo".getBytes(), zset.get().iterator().next());
View Full Code Here

  jedis.set("string", "foo");

  Transaction t = jedis.multi();
  Response<String> string = t.get("string");
  string.get();
  t.exec();
    }

    @Test
    public void transactionResponseWithError() {
  Transaction t = jedis.multi();
View Full Code Here

    public void transactionResponseWithError() {
  Transaction t = jedis.multi();
  t.set("foo", "bar");
  Response<Set<String>> error = t.smembers("foo");
  Response<String> r = t.get("foo");
  List<Object> l = t.exec();
  assertEquals(JedisDataException.class, l.get(1).getClass());
  try {
      error.get();
      fail("We expect exception here!");
  } catch (JedisDataException e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.