use of org.redisson.client.RedisConnection in project redisson by redisson.
the class RedisClientTest method testPipeline.
@Test
public void testPipeline() throws InterruptedException, ExecutionException {
RedisClient c = new RedisClient(RedisRunner.getDefaultRedisServerBindAddressAndPort());
RedisConnection conn = c.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);
RPromise<Void> p = new RedissonPromise<Void>();
conn.send(new CommandsData(p, commands));
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);
}
use of org.redisson.client.RedisConnection in project redisson by redisson.
the class RedisClientTest method testBigRequest.
@Test
public void testBigRequest() throws InterruptedException, ExecutionException {
RedisClient c = new RedisClient(RedisRunner.getDefaultRedisServerBindAddressAndPort());
RedisConnection conn = c.connect();
for (int i = 0; i < 50; i++) {
conn.sync(StringCodec.INSTANCE, RedisCommands.HSET, "testmap", i, "2");
}
Map<Object, Object> res = conn.sync(StringCodec.INSTANCE, RedisCommands.HGETALL, "testmap");
assertThat(res.size()).isEqualTo(50);
conn.sync(RedisCommands.FLUSHDB);
}
use of org.redisson.client.RedisConnection in project redisson by redisson.
the class RedisClientTest method testPipelineBigResponse.
@Test
public void testPipelineBigResponse() throws InterruptedException, ExecutionException {
RedisClient c = new RedisClient(RedisRunner.getDefaultRedisServerBindAddressAndPort());
RedisConnection conn = c.connect();
List<CommandData<?, ?>> commands = new ArrayList<CommandData<?, ?>>();
for (int i = 0; i < 1000; i++) {
CommandData<String, String> cmd1 = conn.create(null, RedisCommands.PING);
commands.add(cmd1);
}
RPromise<Void> p = new RedissonPromise<Void>();
conn.send(new CommandsData(p, commands));
for (CommandData<?, ?> commandData : commands) {
commandData.getPromise().get();
}
conn.sync(RedisCommands.FLUSHDB);
}
Aggregations