当前位置: 首页>>代码示例>>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;未经允许,请勿转载。