Search in sources :

Example 11 with RedisClient

use of org.redisson.client.RedisClient 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);
}
Also used : RedisClient(org.redisson.client.RedisClient) RedisConnection(org.redisson.client.RedisConnection) Test(org.junit.Test)

Example 12 with RedisClient

use of org.redisson.client.RedisClient 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);
}
Also used : RedissonPromise(org.redisson.misc.RedissonPromise) ArrayList(java.util.ArrayList) RedisClient(org.redisson.client.RedisClient) CommandsData(org.redisson.client.protocol.CommandsData) CommandData(org.redisson.client.protocol.CommandData) RedisConnection(org.redisson.client.RedisConnection) Test(org.junit.Test)

Aggregations

RedisClient (org.redisson.client.RedisClient)12 RedisConnection (org.redisson.client.RedisConnection)7 Test (org.junit.Test)6 FutureListener (io.netty.util.concurrent.FutureListener)3 ArrayList (java.util.ArrayList)3 RFuture (org.redisson.api.RFuture)3 RedisConnectionException (org.redisson.client.RedisConnectionException)3 RedisPubSubConnection (org.redisson.client.RedisPubSubConnection)3 CommandData (org.redisson.client.protocol.CommandData)3 CommandsData (org.redisson.client.protocol.CommandsData)3 PubSubType (org.redisson.client.protocol.pubsub.PubSubType)3 RPromise (org.redisson.misc.RPromise)3 RedissonPromise (org.redisson.misc.RedissonPromise)3 Future (io.netty.util.concurrent.Future)2 ScheduledFuture (io.netty.util.concurrent.ScheduledFuture)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutorService (java.util.concurrent.ExecutorService)2 RedisException (org.redisson.client.RedisException)2 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1