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();
}
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());
}
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());
}
Aggregations