Search in sources :

Example 11 with ShardedJedisPipeline

use of redis.clients.jedis.ShardedJedisPipeline in project jedis by xetorthio.

the class ShardedJedisPipelineTest method testSyncWithNoCommandQueued.

@Test
public void testSyncWithNoCommandQueued() {
    JedisShardInfo shardInfo1 = new JedisShardInfo(redis1.getHost(), redis1.getPort());
    JedisShardInfo shardInfo2 = new JedisShardInfo(redis2.getHost(), redis2.getPort());
    shardInfo1.setPassword("foobared");
    shardInfo2.setPassword("foobared");
    List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
    shards.add(shardInfo1);
    shards.add(shardInfo2);
    ShardedJedis jedis2 = new ShardedJedis(shards);
    ShardedJedisPipeline pipeline = jedis2.pipelined();
    pipeline.sync();
    jedis2.close();
    jedis2 = new ShardedJedis(shards);
    pipeline = jedis2.pipelined();
    List<Object> resp = pipeline.syncAndReturnAll();
    assertTrue(resp.isEmpty());
    jedis2.close();
}
Also used : ShardedJedis(redis.clients.jedis.ShardedJedis) ArrayList(java.util.ArrayList) ShardedJedisPipeline(redis.clients.jedis.ShardedJedisPipeline) JedisShardInfo(redis.clients.jedis.JedisShardInfo) Test(org.junit.Test)

Example 12 with ShardedJedisPipeline

use of redis.clients.jedis.ShardedJedisPipeline in project jedis by xetorthio.

the class ShardedJedisPipelineTest method pipeline.

@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));
}
Also used : ShardedJedisPipeline(redis.clients.jedis.ShardedJedisPipeline) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 ShardedJedisPipeline (redis.clients.jedis.ShardedJedisPipeline)12 ArrayList (java.util.ArrayList)6 JedisShardInfo (redis.clients.jedis.JedisShardInfo)4 ShardedJedis (redis.clients.jedis.ShardedJedis)4 URI (java.net.URI)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)2 ShardedJedisPool (redis.clients.jedis.ShardedJedisPool)2