Search in sources :

Example 1 with BatchOptions

use of org.redisson.api.BatchOptions in project redisson by redisson.

the class RedissonConnection method multi.

@Override
public void multi() {
    if (isQueueing()) {
        return;
    }
    if (isPipelined()) {
        BatchOptions options = BatchOptions.defaults().executionMode(ExecutionMode.IN_MEMORY_ATOMIC);
        this.executorService = new CommandBatchService(executorService, options);
        return;
    }
    BatchOptions options = BatchOptions.defaults().executionMode(ExecutionMode.REDIS_WRITE_ATOMIC);
    this.executorService = new CommandBatchService(executorService, options);
}
Also used : CommandBatchService(org.redisson.command.CommandBatchService) BatchOptions(org.redisson.api.BatchOptions)

Example 2 with BatchOptions

use of org.redisson.api.BatchOptions in project redisson by redisson.

the class RedissonConnection method openPipeline.

@Override
public void openPipeline() {
    BatchOptions options = BatchOptions.defaults().executionMode(ExecutionMode.IN_MEMORY);
    this.executorService = new CommandBatchService(executorService, options);
}
Also used : CommandBatchService(org.redisson.command.CommandBatchService) BatchOptions(org.redisson.api.BatchOptions)

Example 3 with BatchOptions

use of org.redisson.api.BatchOptions in project redisson by redisson.

the class RedissonBatchRxTest method testConnectionLeakAfterError.

@Test
public void testConnectionLeakAfterError() {
    Config config = BaseTest.createConfig();
    config.useSingleServer().setRetryInterval(100).setTimeout(200).setConnectionMinimumIdleSize(1).setConnectionPoolSize(1);
    RedissonRxClient redisson = Redisson.create(config).rxJava();
    BatchOptions batchOptions = BatchOptions.defaults().executionMode(ExecutionMode.REDIS_WRITE_ATOMIC);
    RBatchRx batch = redisson.createBatch(batchOptions);
    for (int i = 0; i < 25000; i++) {
        batch.getBucket("test").set(123);
    }
    try {
        sync(batch.execute());
        Assertions.fail();
    } catch (Exception e) {
    // skip
    }
    sync(redisson.getBucket("test3").set(4));
    assertThat(sync(redisson.getBucket("test3").get())).isEqualTo(4);
    batch = redisson.createBatch(batchOptions);
    batch.getBucket("test1").set(1);
    batch.getBucket("test2").set(2);
    sync(batch.execute());
    assertThat(sync(redisson.getBucket("test1").get())).isEqualTo(1);
    assertThat(sync(redisson.getBucket("test2").get())).isEqualTo(2);
    redisson.shutdown();
}
Also used : Config(org.redisson.config.Config) RBatchRx(org.redisson.api.RBatchRx) RedisException(org.redisson.client.RedisException) FailedToStartRedisException(org.redisson.RedisRunner.FailedToStartRedisException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) RedissonRxClient(org.redisson.api.RedissonRxClient) BatchOptions(org.redisson.api.BatchOptions) BaseTest(org.redisson.BaseTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BatchOptions (org.redisson.api.BatchOptions)3 CommandBatchService (org.redisson.command.CommandBatchService)2 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 BaseTest (org.redisson.BaseTest)1 FailedToStartRedisException (org.redisson.RedisRunner.FailedToStartRedisException)1 RBatchRx (org.redisson.api.RBatchRx)1 RedissonRxClient (org.redisson.api.RedissonRxClient)1 RedisException (org.redisson.client.RedisException)1 Config (org.redisson.config.Config)1