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

The following examples show how to use org.redisson.api.RMap#clear() . 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: RedissionUtilsTest.java    From Redis_Learning with Apache License 2.0 6 votes vote down vote up
/** 
 * RMap  ӳ��Ϊ  redis server �� hash ���� 
 * ��Ϊ 
 * put(���ؼ�ֵ) �� fast(����״̬) 
 * ͬ��    �첽 
 * redis server ����: 
 * �鿴���м�---->keys * 
 * �鿴key������--->type testMap 
 * �鿴key��ֵ ---->hgetall testMap 
 * @throws InterruptedException 
 * @throws ExecutionException 
 */  
@Test  
public void testGetRMap() throws InterruptedException, ExecutionException {  
    RMap<String, Integer> rMap=RedissionUtils.getInstance().getRMap(redisson, "testMap");  
    //�������  
    rMap.clear();  
    //���key-value ����֮ǰ��������ֵ  
    Integer firrtInteger=rMap.put("111", 111);  
    System.out.println(firrtInteger);  
    //���key-value ����֮ǰ��������ֵ  
    Integer secondInteger=rMap.putIfAbsent("222", 222);  
    System.out.println(secondInteger);  
    //�Ƴ�key-value  
    Integer thirdInteger=rMap.remove("222");  
    System.out.println(thirdInteger);  
    //���key-value ������֮ǰ��������ֵ  
    boolean third=rMap.fastPut("333", 333);  
    System.out.println(third);   
    //��������  
    for(String key :rMap.keySet()){  
        System.out.println(key+":"+rMap.get(key));  
    }  
      
}
 
Example 2
Source File: BaseMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadAllReplaceValues() {
    Map<String, String> cache = new HashMap<>();
    for (int i = 0; i < 10; i++) {
        cache.put("" + i, "" + i + "" + i);
    }
    
    RMap<String, String> map = getLoaderTestMap("test", cache);
    
    map.put("0", "010");
    map.put("5", "555");
    map.loadAll(false, 2);
    assertThat(map.size()).isEqualTo(10);
    assertThat(map.get("0")).isEqualTo("010");
    assertThat(map.get("5")).isEqualTo("555");
    map.clear();
    
    map.put("0", "010");
    map.put("5", "555");
    map.loadAll(true, 2);
    assertThat(map.size()).isEqualTo(10);
    assertThat(map.get("0")).isEqualTo("00");
    assertThat(map.get("5")).isEqualTo("55");
    destroy(map);
}
 
Example 3
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 4
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);
}