Search in sources :

Example 1 with DynamicMemoryCacheManager

use of com.diboot.core.cache.DynamicMemoryCacheManager in project diboot by dibo-software.

the class CacheTest method testCache.

@Test
public void testCache() {
    String CACHE_TMPL = "CODE_TMPL";
    Map<String, Dictionary> dictionaryMap = new HashMap<>();
    dictionaryMap.put("G", new Dictionary().setType("GENDER"));
    DynamicMemoryCacheManager cacheManager = new DynamicMemoryCacheManager(1, CACHE_TMPL);
    cacheManager.putCacheObj(CACHE_TMPL, "version", dictionaryMap);
    Map<String, Dictionary> dictionaryMapCache = cacheManager.getCacheObj(CACHE_TMPL, "version", Map.class);
    Assert.assertTrue(dictionaryMapCache.get("G").getType().equals("GENDER"));
    boolean isExpired = cacheManager.isExpired(CACHE_TMPL, "version");
    Assert.assertFalse(isExpired);
/*try{
            Thread.sleep(60*1000);
        }
        catch (Exception e){
            e.printStackTrace();
        }
        isExpired = cacheManager.isExpired(CACHE_TMPL, "version");
        Assert.assertTrue(isExpired);*/
}
Also used : Dictionary(com.diboot.core.entity.Dictionary) DynamicMemoryCacheManager(com.diboot.core.cache.DynamicMemoryCacheManager) Test(org.junit.Test)

Aggregations

DynamicMemoryCacheManager (com.diboot.core.cache.DynamicMemoryCacheManager)1 Dictionary (com.diboot.core.entity.Dictionary)1 Test (org.junit.Test)1