Package redis.clients.jedis

Examples of redis.clients.jedis.ShardedJedisPipeline


    }

    @Test
    public void pipeline() throws UnsupportedEncodingException {
  ShardedJedisPipeline p = jedis.pipelined();
  p.set("foo", "bar");
  p.get("foo");
  List<Object> results = p.syncAndReturnAll();

  assertEquals(2, results.size());
  assertEquals("OK", results.get(0));
  assertEquals("bar", results.get(1));
    }
View Full Code Here


  jedis.lpush("list", "foo");
  jedis.hset("hash", "foo", "bar");
  jedis.zadd("zset", 1, "foo");
  jedis.sadd("set", "foo");

  ShardedJedisPipeline p = jedis.pipelined();
  Response<String> string = p.get("string");
  Response<Long> del = p.del("string");
  Response<String> emptyString = p.get("string");
  Response<String> list = p.lpop("list");
  Response<String> hash = p.hget("hash", "foo");
  Response<Set<String>> zset = p.zrange("zset", 0, -1);
  Response<String> set = p.spop("set");
  Response<Boolean> blist = p.exists("list");
  Response<Double> zincrby = p.zincrby("zset", 1, "foo");
  Response<Long> zcard = p.zcard("zset");
  p.lpush("list", "bar");
  Response<List<String>> lrange = p.lrange("list", 0, -1);
  Response<Map<String, String>> hgetAll = p.hgetAll("hash");
  p.sadd("set", "foo");
  Response<Set<String>> smembers = p.smembers("set");
  Response<Set<Tuple>> zrangeWithScores = p.zrangeWithScores("zset", 0,
    -1);
  p.sync();

  assertEquals("foo", string.get());
  assertEquals(Long.valueOf(1), del.get());
  assertNull(emptyString.get());
  assertEquals("foo", list.get());
View Full Code Here

    @Test(expected = JedisDataException.class)
    public void pipelineResponseWithinPipeline() {
  jedis.set("string", "foo");

  ShardedJedisPipeline p = jedis.pipelined();
  Response<String> string = p.get("string");
  string.get();
  p.sync();
    }
View Full Code Here

  p.sync();
    }

    @Test
    public void canRetrieveUnsetKey() {
  ShardedJedisPipeline p = jedis.pipelined();
  Response<String> shouldNotExist = p.get(UUID.randomUUID().toString());
  p.sync();
  assertNull(shouldNotExist.get());
    }
View Full Code Here

  ShardedJedis jedis = pool.getResource();
  jedis.set("pipelined", String.valueOf(0));
  jedis.set("pipelined2", String.valueOf(0));

  ShardedJedisPipeline pipeline = jedis.pipelined();

  pipeline.incr("pipelined");
  pipeline.incr("pipelined2");

  jedis.resetState();

  pipeline = jedis.pipelined();
  pipeline.incr("pipelined");
  pipeline.incr("pipelined2");
  List<Object> results = pipeline.syncAndReturnAll();

  assertEquals(2, results.size());
  pool.returnResource(jedis);
  pool.destroy();
    }
View Full Code Here

TOP

Related Classes of redis.clients.jedis.ShardedJedisPipeline

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.