當前位置: 首頁>>代碼示例>>Java>>正文


Java CacheManager.newInstance方法代碼示例

本文整理匯總了Java中net.sf.ehcache.CacheManager.newInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java CacheManager.newInstance方法的具體用法?Java CacheManager.newInstance怎麽用?Java CacheManager.newInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.ehcache.CacheManager的用法示例。


在下文中一共展示了CacheManager.newInstance方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testEhcache

import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
@Test
public void testEhcache() {
    // Creating a CacheManager based on a specified configuration file.
    CacheManager manager = CacheManager.newInstance("src/main/resources/ehcache.xml");
    // obtains a Cache called sampleCache1, which has been preconfigured in the configuration file
    Cache cache = manager.getCache("sampleCache1");
    // puts an element into a cache
    Element element = new Element("key1", "哈哈");
    cache.put(element);
    //The following gets a NonSerializable value from an element with a key of key1.
    Object value = element.getObjectValue();
    System.out.println(value.toString());
    manager.shutdown();
}
 
開發者ID:Zephery,項目名稱:newblog,代碼行數:15,代碼來源:TestEhcache.java

示例2: cacheExposesMetrics

import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
@Test
void cacheExposesMetrics() {
    CacheManager cacheManager = CacheManager.newInstance();
    cacheManager.addCache("a");
    Cache c = cacheManager.getCache("a");

    MeterRegistry registry = new SimpleMeterRegistry();
    EhCache2Metrics.monitor(registry, c, "ehcache", emptyList());

    c.put(new Element("k", "v", 1));

    registry.mustFind("ehcache.size").tags("name", "a").gauge();
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:14,代碼來源:EhCache2MetricsTest.java

示例3: setUp

import net.sf.ehcache.CacheManager; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  registry = RegistryService.getMetricRegistry();

  cacheManager = CacheManager.newInstance();
  cache = cacheManager.addCacheIfAbsent(cacheName);
  presetElements = IntStream.range(0, 1000).boxed()
      .collect(Collectors.toMap(i -> UUID.randomUUID().toString(), i -> i));
  presetElementKeys = new ArrayList<>(presetElements.keySet());

}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:12,代碼來源:EHCacheInstrumentationTest.java


注:本文中的net.sf.ehcache.CacheManager.newInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。