Search in sources :

Example 1 with RBucket

use of org.redisson.api.RBucket 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 2 with RBucket

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

the class RedissonReferenceTest method testBatch.

@Test
public void testBatch() {
    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();
    batch = redisson.createBatch();
    batch.getBucket("b1").getAsync();
    batch.getBucket("b2").getAsync();
    batch.getBucket("b3").getAsync();
    List<RBucket> result = (List<RBucket>) batch.execute();
    assertEquals("b2", result.get(0).getName());
    assertEquals("b3", result.get(1).getName());
    assertEquals("b1", result.get(2).getName());
}
Also used : RBucket(org.redisson.api.RBucket) RBatch(org.redisson.api.RBatch) RLiveObject(org.redisson.api.RLiveObject) List(java.util.List) Test(org.junit.Test)

Example 3 with RBucket

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

the class RedissonReferenceTest method testBasic.

@Test
public void testBasic() {
    RBucket<Object> b1 = redisson.getBucket("b1");
    RBucket<Object> b2 = redisson.getBucket("b2");
    RBucket<Object> b3 = redisson.getBucket("b3");
    b2.set(b3);
    b1.set(redisson.getBucket("b2"));
    assertTrue(b1.get().getClass().equals(RedissonBucket.class));
    assertEquals("b3", ((RBucket) ((RBucket) b1.get()).get()).getName());
    RBucket<Object> b4 = redisson.getBucket("b4");
    b4.set(redisson.getMapCache("testCache"));
    assertTrue(b4.get() instanceof RedissonMapCache);
    ((RedissonMapCache) b4.get()).fastPut(b1, b2, 1, TimeUnit.MINUTES);
    assertEquals("b2", ((RBucket) ((RedissonMapCache) b4.get()).get(b1)).getName());
    RBucket<Object> b5 = redisson.getBucket("b5");
    RLiveObjectService service = redisson.getLiveObjectService();
    RedissonLiveObjectServiceTest.TestREntity rlo = new RedissonLiveObjectServiceTest.TestREntity("123");
    rlo = service.persist(rlo);
    rlo.setName("t1");
    rlo.setValue("t2");
    b5.set(rlo);
    assertTrue(redisson.getBucket("b5").get() instanceof RLiveObject);
    assertEquals("t1", ((RedissonLiveObjectServiceTest.TestREntity) redisson.getBucket("b5").get()).getName());
    assertEquals("t2", ((RedissonLiveObjectServiceTest.TestREntity) redisson.getBucket("b5").get()).getValue());
}
Also used : RBucket(org.redisson.api.RBucket) RLiveObject(org.redisson.api.RLiveObject) RLiveObject(org.redisson.api.RLiveObject) RLiveObjectService(org.redisson.api.RLiveObjectService) Test(org.junit.Test)

Aggregations

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