use of org.redisson.client.protocol.CommandsData in project redisson by redisson.
the class RedisClientTest method testPipeline.
@Test
public void testPipeline() throws InterruptedException, ExecutionException {
RedisConnection conn = redisClient.connect();
conn.sync(StringCodec.INSTANCE, RedisCommands.SET, "test", 0);
List<CommandData<?, ?>> commands = new ArrayList<CommandData<?, ?>>();
CommandData<String, String> cmd1 = conn.create(null, RedisCommands.PING);
commands.add(cmd1);
CommandData<Long, Long> cmd2 = conn.create(null, RedisCommands.INCR, "test");
commands.add(cmd2);
CommandData<Long, Long> cmd3 = conn.create(null, RedisCommands.INCR, "test");
commands.add(cmd3);
CommandData<String, String> cmd4 = conn.create(null, RedisCommands.PING);
commands.add(cmd4);
CompletableFuture<Void> p = new CompletableFuture<Void>();
conn.send(new CommandsData(p, commands, false, false));
assertThat(cmd1.getPromise().get()).isEqualTo("PONG");
assertThat(cmd2.getPromise().get()).isEqualTo(1);
assertThat(cmd3.getPromise().get()).isEqualTo(2);
assertThat(cmd4.getPromise().get()).isEqualTo("PONG");
conn.sync(RedisCommands.FLUSHDB);
}
Aggregations