use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonTransactionalSetTest method testRemoveAll.
@Test
public void testRemoveAll() {
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("3");
set.removeAll(putSet);
assertThat(s).containsOnly("1", "3");
assertThat(set).containsOnly("1");
t.commit();
assertThat(s).containsOnly("1");
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonBaseTransactionalMapTest method testPutAll.
@Test
public void testPutAll() {
RMap<String, String> m = getMap();
m.put("1", "2");
m.put("3", "4");
RTransaction t = redisson.createTransaction(TransactionOptions.defaults());
RMap<String, String> map = getTransactionalMap(t);
Map<String, String> putMap = new HashMap<String, String>();
putMap.put("4", "5");
putMap.put("6", "7");
map.putAll(putMap);
assertThat(m.keySet()).containsOnly("1", "3");
t.commit();
assertThat(m.keySet()).containsOnly("1", "3", "4", "6");
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonBaseTransactionalMapTest method testGetAll.
@Test
public void testGetAll() {
RMap<String, String> m = getMap();
m.put("1", "2");
m.put("3", "4");
RTransaction t = redisson.createTransaction(TransactionOptions.defaults());
RMap<String, String> map = getTransactionalMap(t);
assertThat(map.getAll(new HashSet<String>(Arrays.asList("1", "3"))).values()).containsOnly("2", "4");
t.commit();
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonTransactionalBucketTest method testTrySet.
@Test
public void testTrySet() {
RBucket<String> b = redisson.getBucket("test");
b.set("123");
RTransaction transaction = redisson.createTransaction(TransactionOptions.defaults());
RBucket<String> bucket = transaction.getBucket("test");
assertThat(bucket.trySet("0")).isFalse();
assertThat(bucket.delete()).isTrue();
assertThat(bucket.trySet("324")).isTrue();
assertThat(bucket.trySet("43")).isFalse();
transaction.commit();
assertThat(redisson.getKeys().count()).isEqualTo(1);
assertThat(b.get()).isEqualTo("324");
}
use of org.redisson.api.RTransaction in project redisson by redisson.
the class RedissonTransactionalBucketTest method testCompareAndSet.
@Test
public void testCompareAndSet() {
RBucket<String> b = redisson.getBucket("test");
b.set("123");
RTransaction transaction = redisson.createTransaction(TransactionOptions.defaults());
RBucket<String> bucket = transaction.getBucket("test");
assertThat(bucket.compareAndSet("0", "434")).isFalse();
assertThat(bucket.get()).isEqualTo("123");
assertThat(bucket.compareAndSet("123", "232")).isTrue();
assertThat(bucket.get()).isEqualTo("232");
transaction.commit();
assertThat(redisson.getKeys().count()).isEqualTo(1);
assertThat(b.get()).isEqualTo("232");
}
Aggregations