use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonTransactionalBucketTest method testGetAndRemove.
@Test
public void testGetAndRemove() {
RBucket<String> m = redisson.getBucket("test");
m.set("123");
RTransaction transaction = redisson.createTransaction(TransactionOptions.defaults());
RBucket<String> set = transaction.getBucket("test");
assertThat(set.get()).isEqualTo("123");
assertThat(set.size()).isEqualTo(6);
assertThat(set.getAndDelete()).isEqualTo("123");
assertThat(set.size()).isEqualTo(0);
assertThat(set.get()).isNull();
assertThat(set.getAndDelete()).isNull();
transaction.commit();
assertThat(redisson.getKeys().count()).isEqualTo(0);
assertThat(m.get()).isNull();
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonTransactionalLocalCachedMapTest method testPut.
@Test
public void testPut() throws InterruptedException {
RLocalCachedMap<String, String> m1 = redisson.getLocalCachedMap("test", LocalCachedMapOptions.defaults());
m1.put("1", "2");
m1.put("3", "4");
RLocalCachedMap<String, String> m2 = redisson.getLocalCachedMap("test", LocalCachedMapOptions.defaults());
m2.get("1");
m2.get("3");
RTransaction transaction = redisson.createTransaction(TransactionOptions.defaults());
RMap<String, String> map = transaction.getLocalCachedMap(m1);
assertThat(map.put("3", "5")).isEqualTo("4");
assertThat(map.get("3")).isEqualTo("5");
assertThat(m1.get("3")).isEqualTo("4");
assertThat(m2.get("3")).isEqualTo("4");
transaction.commit();
assertThat(m1.get("3")).isEqualTo("5");
assertThat(m2.get("3")).isEqualTo("5");
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class TransactionalBean method testCommitAfterRollback.
@Transactional
public void testCommitAfterRollback() {
RTransaction transaction = transactionManager.getCurrentTransaction();
transaction.getMap("test2").put("1", "2");
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class TransactionalBean method testNestedNewTransaction.
@Transactional
public void testNestedNewTransaction() {
RTransaction transaction = transactionManager.getCurrentTransaction();
transaction.getMap("tr1").put("1", "0");
transactionalBean2.testInNewTransaction();
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class TransactionalBean method testTransactionIsNotNull.
@Transactional
public void testTransactionIsNotNull() {
RTransaction transaction = transactionManager.getCurrentTransaction();
assertThat(transaction).isNotNull();
}
Aggregations