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


Java CacheManagerBuilder類代碼示例

本文整理匯總了Java中org.ehcache.CacheManagerBuilder的典型用法代碼示例。如果您正苦於以下問題:Java CacheManagerBuilder類的具體用法?Java CacheManagerBuilder怎麽用?Java CacheManagerBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: EHCache3Manager

import org.ehcache.CacheManagerBuilder; //導入依賴的package包/類
public EHCache3Manager() throws ClassNotFoundException, SAXException, InstantiationException, IOException, IllegalAccessException {
    URL url = getClass().getResource("/activejdbc-ehcache.xml");
    if(url == null){
        throw new InitException("You are using " + getClass().getName() + " but failed to provide a EHCache configuration file on classpath: activejdbc-ehcache.xml");
    }

    XmlConfiguration xmlConfiguration = new XmlConfiguration(url);

    cacheTemplate = xmlConfiguration.newCacheConfigurationBuilderFromTemplate("activejdbc", String.class, Object.class);

    if(cacheTemplate == null){
        throw new InitException("Please, provide a <cache-template name=\"activejdbc\"> element in  activejdbc-ehcache.xml file");
    }
    cacheManager = CacheManagerBuilder.newCacheManager(xmlConfiguration);
    cacheManager.init();
}
 
開發者ID:javalite,項目名稱:activejdbc,代碼行數:17,代碼來源:EHCache3Manager.java

示例2: main

import org.ehcache.CacheManagerBuilder; //導入依賴的package包/類
public static void main(String[] args){
    CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
            .withCache("preConfigured",
                    CacheConfigurationBuilder.newCacheConfigurationBuilder().buildConfig(Long.class, String.class))
            .build(true);

    Cache<Long, String> preConfigured
            = cacheManager.getCache("preConfigured", Long.class, String.class);

    Cache<Long, TestData> myCache = cacheManager.createCache("myCache",
            CacheConfigurationBuilder.newCacheConfigurationBuilder().buildConfig(Long.class, TestData.class));
    Cache<Long, TestData2> myCache2 = cacheManager.createCache("myCache2",
            CacheConfigurationBuilder.newCacheConfigurationBuilder().buildConfig(Long.class, TestData2.class));

    TestData data=new TestData();
    myCache.put(1L, data);
    myCache.put(1L, data);
    myCache.put(1L,new TestData());
    myCache.put(1L, data);
    myCache2.put(2l,data.testData2);
    data.a=30;
    data.testData2.a=50;
    TestData value = myCache.get(1L);
    
    System.out.println(value);

    cacheManager.close();
}
 
開發者ID:xuerong,項目名稱:MMServerEngine,代碼行數:29,代碼來源:TestEhcache.java

示例3: getCacheManager

import org.ehcache.CacheManagerBuilder; //導入依賴的package包/類
private synchronized PersistentCacheManager getCacheManager()
{
  if (this.manager == null)
  {
    this.manager = CacheManagerBuilder.newCacheManagerBuilder().with(new CacheManagerPersistenceConfiguration(new File(this.cacheFileLocation, this.cacheName))).build(true);
  }

  return this.manager;
}
 
開發者ID:terraframe,項目名稱:Runway-SDK,代碼行數:10,代碼來源:Diskstore.java


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