use of org.redisson.api.RTransactionReactive in project redisson by redisson.
the class RedissonTransactionalBucketReactiveTest method testTimeout.
@Test
public void testTimeout() throws InterruptedException {
RBucketReactive<String> b = redisson.getBucket("test");
sync(b.set("123"));
RTransactionReactive transaction = redisson.createTransaction(TransactionOptions.defaults().timeout(3, TimeUnit.SECONDS));
RBucketReactive<String> bucket = transaction.getBucket("test");
sync(bucket.set("234"));
Thread.sleep(3000);
try {
sync(transaction.commit());
Assertions.fail();
} catch (TransactionException e) {
// skip
}
Thread.sleep(1000);
assertThat(sync(b.get())).isEqualTo("123");
}
use of org.redisson.api.RTransactionReactive in project redisson by redisson.
the class RedissonTransactionalBucketReactiveTest method testTrySet.
@Test
public void testTrySet() {
RBucketReactive<String> b = redisson.getBucket("test");
sync(b.set("123"));
RTransactionReactive transaction = redisson.createTransaction(TransactionOptions.defaults());
RBucketReactive<String> bucket = transaction.getBucket("test");
assertThat(sync(bucket.trySet("0"))).isFalse();
assertThat(sync(bucket.delete())).isTrue();
assertThat(sync(bucket.trySet("324"))).isTrue();
assertThat(sync(bucket.trySet("43"))).isFalse();
sync(transaction.commit());
assertThat(sync(redisson.getKeys().count())).isEqualTo(1);
assertThat(sync(b.get())).isEqualTo("324");
}
use of org.redisson.api.RTransactionReactive in project redisson by redisson.
the class RedissonTransactionalBucketReactiveTest method testRollback.
@Test
public void testRollback() {
RBucketReactive<Object> b = redisson.getBucket("test");
sync(b.set("1234"));
RTransactionReactive transaction = redisson.createTransaction(TransactionOptions.defaults());
RBucketReactive<Object> bucket = transaction.getBucket("test");
assertThat(sync(bucket.get())).isEqualTo("1234");
assertThat(sync(bucket.getAndDelete())).isEqualTo("1234");
assertThat(sync(b.get())).isEqualTo("1234");
sync(transaction.rollback());
assertThat(sync(redisson.getKeys().count())).isEqualTo(1);
assertThat(sync(b.get())).isEqualTo("1234");
}
use of org.redisson.api.RTransactionReactive in project redisson by redisson.
the class RedissonTransactionalBucketReactiveTest method testSet.
@Test
public void testSet() {
RBucketReactive<String> b = redisson.getBucket("test");
sync(b.set("123"));
RTransactionReactive transaction = redisson.createTransaction(TransactionOptions.defaults());
RBucketReactive<String> bucket = transaction.getBucket("test");
sync(bucket.set("234"));
assertThat(sync(bucket.get())).isEqualTo("234");
sync(transaction.commit());
assertThat(sync(redisson.getKeys().count())).isEqualTo(1);
assertThat(sync(b.get())).isEqualTo("234");
}
Aggregations