Java Code Examples for org.redisson.api.RMap#putAll()

The following examples show how to use org.redisson.api.RMap#putAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testPutAll() {
    RMap<Integer, String> map = getMap("simple");
    map.put(1, "1");
    map.put(2, "2");
    map.put(3, "3");

    Map<Integer, String> joinMap = new HashMap<Integer, String>();
    joinMap.put(4, "4");
    joinMap.put(5, "5");
    joinMap.put(6, "6");
    map.putAll(joinMap);

    assertThat(map.keySet()).containsOnly(1, 2, 3, 4, 5, 6);
    destroy(map);
}
 
Example 2
Source File: BaseMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetAllBig() {
    Map<Integer, String> joinMap = new HashMap<Integer, String>();
    for (int i = 0; i < 10000; i++) {
        joinMap.put(i, "" + i);
    }
    
    RMap<Integer, String> map = getMap("simple");
    map.putAll(joinMap);
    
    Map<Integer, String> s = map.getAll(joinMap.keySet());
    assertThat(s).isEqualTo(joinMap);
    
    assertThat(map.size()).isEqualTo(joinMap.size());
    destroy(map);
}
 
Example 3
Source File: BaseMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriterPutAll() {
    Map<String, String> store = new HashMap<>();
    RMap<String, String> map = getWriterTestMap("test", store);

    Map<String, String> newMap = new HashMap<>();
    newMap.put("1", "11");
    newMap.put("2", "22");
    newMap.put("3", "33");
    map.putAll(newMap);
    
    Map<String, String> expected = new HashMap<>();
    expected.put("1", "11");
    expected.put("2", "22");
    expected.put("3", "33");
    assertThat(store).isEqualTo(expected);
    destroy(map);
}
 
Example 4
Source File: RedissonBaseTransactionalMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@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");
}
 
Example 5
Source File: MultiCache.java    From mPaaS with Apache License 2.0 5 votes vote down vote up
/** 写 */
public void hset(String key, Map<String, ?> map, long timeToLive,
                 TimeUnit timeUnit) {
    Map<String, Object> cache = getThreadLocal();
    if (cache != null) {
        cache.put(key, map);
    }
    RMap<String, Object> rmap = redisson.getMap(key,
            JsonJacksonCodec.INSTANCE);
    rmap.clear();
    rmap.putAll(map);
    rmap.expire(timeToLive, timeUnit);
}
 
Example 6
Source File: MultiCache.java    From mPass with Apache License 2.0 5 votes vote down vote up
/** 写 */
public void hset(String key, Map<String, ?> map, long timeToLive,
                 TimeUnit timeUnit) {
    Map<String, Object> cache = getThreadLocal();
    if (cache != null) {
        cache.put(key, map);
    }
    RMap<String, Object> rmap = redisson.getMap(key,
            JsonJacksonCodec.INSTANCE);
    rmap.clear();
    rmap.putAll(map);
    rmap.expire(timeToLive, timeUnit);
}
 
Example 7
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testOrdering() {
    Map<String, String> map = new LinkedHashMap<String, String>();

    // General player data
    map.put("name", "123");
    map.put("ip", "4124");
    map.put("rank", "none");
    map.put("tokens", "0");
    map.put("coins", "0");

    // Arsenal player statistics
    map.put("ar_score", "0");
    map.put("ar_gameswon", "0");
    map.put("ar_gameslost", "0");
    map.put("ar_kills", "0");
    map.put("ar_deaths", "0");

    RMap<String, String> rmap = getMap("123");
    Assume.assumeTrue(!(rmap instanceof RLocalCachedMap));
    
    rmap.putAll(map);

    assertThat(rmap.keySet()).containsExactlyElementsOf(map.keySet());
    assertThat(rmap.readAllKeySet()).containsExactlyElementsOf(map.keySet());
    
    assertThat(rmap.values()).containsExactlyElementsOf(map.values());
    assertThat(rmap.readAllValues()).containsExactlyElementsOf(map.values());
    
    assertThat(rmap.entrySet()).containsExactlyElementsOf(map.entrySet());
    assertThat(rmap.readAllEntrySet()).containsExactlyElementsOf(map.entrySet());
    destroy(rmap);
}
 
Example 8
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutAllBatched() {
    RMap<Integer, String> map = getMap("simple");
    map.put(1, "1");
    map.put(2, "2");
    map.put(3, "3");

    Map<Integer, String> joinMap = new HashMap<Integer, String>();
    joinMap.put(4, "4");
    joinMap.put(5, "5");
    joinMap.put(6, "6");
    map.putAll(joinMap, 5);

    assertThat(map.keySet()).containsOnly(1, 2, 3, 4, 5, 6);
    
    Map<Integer, String> joinMap2 = new HashMap<Integer, String>();
    joinMap2.put(7, "7");
    joinMap2.put(8, "8");
    joinMap2.put(9, "9");
    joinMap2.put(10, "10");
    joinMap2.put(11, "11");
    map.putAll(joinMap2, 5);
    
    assertThat(map.keySet()).containsOnly(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);

    Map<Integer, String> joinMap3 = new HashMap<Integer, String>();
    joinMap3.put(12, "12");
    joinMap3.put(13, "13");
    joinMap3.put(14, "14");
    joinMap3.put(15, "15");
    joinMap3.put(16, "16");
    joinMap3.put(17, "17");
    joinMap3.put(18, "18");
    map.putAll(joinMap3, 5);
    
    assertThat(map.keySet()).containsOnly(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18);
    
    destroy(map);
}
 
Example 9
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutAllBig() {
    Map<Integer, String> joinMap = new HashMap<Integer, String>();
    for (int i = 0; i < 100000; i++) {
        joinMap.put(i, "" + i);
    }
    
    RMap<Integer, String> map = getMap("simple");
    map.putAll(joinMap);
    
    assertThat(map.size()).isEqualTo(joinMap.size());
    destroy(map);
}