Search in sources :

Example 1 with RBatchReactive

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

the class RedissonReferenceReactiveTest method testBatch.

@Test
public void testBatch() throws InterruptedException {
    RBatchReactive batch = redisson.createBatch();
    RBucketReactive<Object> b1 = batch.getBucket("b1");
    RBucketReactive<Object> b2 = batch.getBucket("b2");
    RBucketReactive<Object> b3 = batch.getBucket("b3");
    b2.set(b3);
    b1.set(b2);
    b3.set(b1);
    sync(batch.execute());
    batch = redisson.createBatch();
    batch.getBucket("b1").get();
    batch.getBucket("b2").get();
    batch.getBucket("b3").get();
    List<RBucketReactive> result = (List<RBucketReactive>) sync(batch.execute());
    assertEquals("b2", result.get(0).getName());
    assertEquals("b3", result.get(1).getName());
    assertEquals("b1", result.get(2).getName());
}
Also used : RBucketReactive(org.redisson.api.RBucketReactive) List(java.util.List) RBatchReactive(org.redisson.api.RBatchReactive) Test(org.junit.Test)

Example 2 with RBatchReactive

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

the class RedissonReferenceReactiveTest method testReactiveToNormal.

@Test
public void testReactiveToNormal() throws InterruptedException {
    RBatchReactive batch = redisson.createBatch();
    RBucketReactive<Object> b1 = batch.getBucket("b1");
    RBucketReactive<Object> b2 = batch.getBucket("b2");
    RBucketReactive<Object> b3 = batch.getBucket("b3");
    b2.set(b3);
    b1.set(b2);
    b3.set(b1);
    sync(batch.execute());
    RedissonClient lredisson = Redisson.create(redisson.getConfig());
    RBatch b = lredisson.createBatch();
    b.getBucket("b1").getAsync();
    b.getBucket("b2").getAsync();
    b.getBucket("b3").getAsync();
    List<RBucket> result = (List<RBucket>) b.execute();
    assertEquals("b2", result.get(0).getName());
    assertEquals("b3", result.get(1).getName());
    assertEquals("b1", result.get(2).getName());
    lredisson.shutdown();
}
Also used : RBucket(org.redisson.api.RBucket) RedissonClient(org.redisson.api.RedissonClient) RBatch(org.redisson.api.RBatch) List(java.util.List) RBatchReactive(org.redisson.api.RBatchReactive) Test(org.junit.Test)

Example 3 with RBatchReactive

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

the class RedissonReferenceTest method testNormalToReactive.

@Test
public void testNormalToReactive() {
    RBatch batch = redisson.createBatch();
    RBucketAsync<Object> b1 = batch.getBucket("b1");
    RBucketAsync<Object> b2 = batch.getBucket("b2");
    RBucketAsync<Object> b3 = batch.getBucket("b3");
    b2.setAsync(b3);
    b1.setAsync(b2);
    b3.setAsync(b1);
    batch.execute();
    RBatchReactive b = Redisson.createReactive(redisson.getConfig()).createBatch();
    b.getBucket("b1").get();
    b.getBucket("b2").get();
    b.getBucket("b3").get();
    List<RBucketReactive> result = (List<RBucketReactive>) BaseReactiveTest.sync(b.execute());
    assertEquals("b2", result.get(0).getName());
    assertEquals("b3", result.get(1).getName());
    assertEquals("b1", result.get(2).getName());
}
Also used : RBatch(org.redisson.api.RBatch) RBucketReactive(org.redisson.api.RBucketReactive) RLiveObject(org.redisson.api.RLiveObject) List(java.util.List) RBatchReactive(org.redisson.api.RBatchReactive) Test(org.junit.Test)

Aggregations

List (java.util.List)3 Test (org.junit.Test)3 RBatchReactive (org.redisson.api.RBatchReactive)3 RBatch (org.redisson.api.RBatch)2 RBucketReactive (org.redisson.api.RBucketReactive)2 RBucket (org.redisson.api.RBucket)1 RLiveObject (org.redisson.api.RLiveObject)1 RedissonClient (org.redisson.api.RedissonClient)1