use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonTransactionalSetTest method testPutAll.
@Test
public void testPutAll() {
RSet<String> s = redisson.getSet("test");
s.add("1");
s.add("3");
RTransaction t = redisson.createTransaction(TransactionOptions.defaults());
RSet<String> set = t.getSet("test");
Set<String> putSet = new HashSet<String>();
putSet.add("4");
putSet.add("6");
set.addAll(putSet);
assertThat(s).containsOnly("1", "3");
assertThat(set).containsOnly("1", "3", "4", "6");
t.commit();
assertThat(s).containsOnly("1", "3", "4", "6");
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonTransactionalSetTest method testAdd.
@Test
public void testAdd() {
RSet<String> s = redisson.getSet("test");
s.add("1");
s.add("3");
RTransaction transaction = redisson.createTransaction(TransactionOptions.defaults());
RSet<String> set = transaction.getSet("test");
assertThat(set.add("4")).isTrue();
assertThat(set.add("3")).isFalse();
assertThat(set.contains("4")).isTrue();
assertThat(s.contains("4")).isFalse();
transaction.commit();
assertThat(s.size()).isEqualTo(3);
assertThat(s.contains("1")).isTrue();
assertThat(s.contains("3")).isTrue();
assertThat(s.contains("4")).isTrue();
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonTransactionalSetTest method testKeySet.
@Test
public void testKeySet() {
RSet<String> s = redisson.getSet("test");
s.add("1");
s.add("3");
RTransaction t = redisson.createTransaction(TransactionOptions.defaults());
RSet<String> set = t.getSet("test");
set.remove("3");
assertThat(set).containsOnly("1");
assertThat(s).containsOnly("1", "3");
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class TransactionalBean2 method testInNewTransaction.
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testInNewTransaction() {
RTransaction transaction = transactionManager.getCurrentTransaction();
transaction.getMap("tr2").put("2", "4");
}
Aggregations