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);*/
}
Aggregations