当前位置: 首页>>代码示例>>Java>>正文


Java EhCacheCacheManager类代码示例

本文整理汇总了Java中org.springframework.cache.ehcache.EhCacheCacheManager的典型用法代码示例。如果您正苦于以下问题:Java EhCacheCacheManager类的具体用法?Java EhCacheCacheManager怎么用?Java EhCacheCacheManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EhCacheCacheManager类属于org.springframework.cache.ehcache包,在下文中一共展示了EhCacheCacheManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager() {
    log.debug("Starting Ehcache");
    cacheManager = net.sf.ehcache.CacheManager.create();
    cacheManager.getConfiguration().setMaxBytesLocalHeap(env.getProperty("cache.ehcache.maxBytesLocalHeap", String.class, "16M"));
    log.debug("Registering Ehcache Metrics gauges");
    Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities();
    for (EntityType<?> entity : entities) {

        String name = entity.getName();
        if (name == null || entity.getJavaType() != null) {
            name = entity.getJavaType().getName();
        }
        Assert.notNull(name, "entity cannot exist without a identifier");

        net.sf.ehcache.Cache cache = cacheManager.getCache(name);
        if (cache != null) {
            cache.getCacheConfiguration().setTimeToLiveSeconds(env.getProperty("cache.timeToLiveSeconds", Long.class, 3600L));
            net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache);
            cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache);
        }
    }
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);
    return ehCacheManager;
}
 
开发者ID:VHAINNOVATIONS,项目名称:BCDS,代码行数:27,代码来源:CacheConfiguration.java

示例2: cacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Ehcache");
    cacheManager = net.sf.ehcache.CacheManager.create();
    cacheManager.getConfiguration().setMaxBytesLocalHeap(jHipsterProperties.getCache().getEhcache().getMaxBytesLocalHeap());
    log.debug("Registering Ehcache Metrics gauges");
    Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities();
    for (EntityType<?> entity : entities) {

        String name = entity.getName();
        if (name == null || entity.getJavaType() != null) {
            name = entity.getJavaType().getName();
        }
        Assert.notNull(name, "entity cannot exist without a identifier");

        net.sf.ehcache.Cache cache = cacheManager.getCache(name);
        if (cache != null) {
            cache.getCacheConfiguration().setTimeToLiveSeconds(jHipsterProperties.getCache().getTimeToLiveSeconds());
            net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache);
            cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache);
        }
    }
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);
    return ehCacheManager;
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:27,代码来源:CacheConfiguration.java

示例3: cacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Ehcache");
    cacheManager = net.sf.ehcache.CacheManager.create();
    cacheManager.getConfiguration().setMaxBytesLocalHeap(jHipsterProperties.getCache().getEhcache().getMaxBytesLocalHeap());
    log.debug("Registering Ehcache Metrics gauges");
    Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities();
    for (EntityType<?> entity : entities) {
        String name = entity.getName();
        if (name == null || entity.getJavaType() != null) {
            name = entity.getJavaType().getName();
        }
        Assert.notNull(name, "entity cannot exist without an identifier");
        reconfigureCache(name, jHipsterProperties);
        for (PluralAttribute pluralAttribute : entity.getPluralAttributes()) {
            reconfigureCache(name + "." + pluralAttribute.getName(), jHipsterProperties);
        }
    }
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);
    return ehCacheManager;
}
 
开发者ID:mraible,项目名称:jhipster-stormpath-example,代码行数:23,代码来源:CacheConfiguration.java

示例4: getObject

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Override
public EhCacheCacheManager getObject() throws Exception {
    if (this.config.getName() == null) {
        this.config.setName(this.beanName);
    }

    this.config.addSizeOfPolicy(new SizeOfPolicyConfiguration().maxDepth(Integer.MAX_VALUE));

    Optional.ofNullable(this.maxBytesLocalDisk).ifPresent(this.config::setMaxBytesLocalDisk);
    Optional.ofNullable(this.maxBytesLocalHeap).ifPresent(this.config::setMaxBytesLocalHeap);
    Optional.ofNullable(this.maxBytesLocalOffHeap).ifPresent(this.config::setMaxBytesLocalOffHeap);

    (this.cacheManager = new EhCacheCacheManager(new CacheManager(this.config))).setTransactionAware(true);

    return this.cacheManager;
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:17,代码来源:CacheManagerFactoryBean.java

示例5: cacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager(ApplicationProperties applicationProperties) {
  log.debug("Starting Ehcache");
  cacheManager = net.sf.ehcache.CacheManager.create();
  cacheManager.getConfiguration().setMaxBytesLocalHeap(applicationProperties.getCache().getEhcache().getMaxBytesLocalHeap());
  log.debug("Registering Ehcache Metrics gauges");
  Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities();
  for (EntityType<?> entity : entities) {
    String name = entity.getName();
    if (name == null || entity.getJavaType() != null) {
      name = entity.getJavaType().getName();
    }
    Assert.notNull(name, "entity cannot exist without a identifier");

    net.sf.ehcache.Cache cache = cacheManager.getCache(name);
    if (cache != null) {
      cache.getCacheConfiguration().setTimeToLiveSeconds(applicationProperties.getCache().getTimeToLiveSeconds());
      net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache);
      cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache);
    }
  }
  EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
  ehCacheManager.setCacheManager(cacheManager);
  return ehCacheManager;
}
 
开发者ID:priitl,项目名称:p2p-webtv,代码行数:26,代码来源:CacheConfiguration.java

示例6: cacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager() {
    log.debug("Starting Ehcache");
    cacheManager = net.sf.ehcache.CacheManager.create();
    cacheManager.getConfiguration().setMaxBytesLocalHeap(env.getProperty("cache.ehcache.maxBytesLocalHeap", String.class, "16M"));
    log.debug("Registring Ehcache Metrics gauges");
    Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities();
    for (EntityType<?> entity : entities) {
        
        String name = entity.getName();
        if (name == null || entity.getJavaType() != null) {
            name = entity.getJavaType().getName();
        }
        Assert.notNull(name, "entity cannot exist without a identifier");
        
        net.sf.ehcache.Cache cache = cacheManager.getCache(name);
        if (cache != null) {
            cache.getCacheConfiguration().setTimeToLiveSeconds(env.getProperty("cache.timeToLiveSeconds", Long.class, 3600L));
            net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache);
            cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache);
        }
    }
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);
    return ehCacheManager;
}
 
开发者ID:la-team,项目名称:lightadmin-jhipster,代码行数:27,代码来源:CacheConfiguration.java

示例7: cacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager() {
    log.debug("Starting Ehcache");
    cacheManager = net.sf.ehcache.CacheManager.create();
    cacheManager.getConfiguration().setMaxBytesLocalHeap(env.getProperty("cache.ehcache.maxBytesLocalHeap", String.class, "16M"));
    log.debug("Registring Ehcache Metrics gauges");
    Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities();
    for (EntityType<?> entity : entities) {
        String name = entity.getJavaType().getName();
        net.sf.ehcache.Cache cache = cacheManager.getCache(name);
        if (cache != null) {
            cache.getCacheConfiguration().setTimeToLiveSeconds(env.getProperty("cache.timeToLiveSeconds", Integer.class, 3600));
            net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache);
            cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache);
        }
    }
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);
    return ehCacheManager;
}
 
开发者ID:ravikiran438,项目名称:cevent-app,代码行数:21,代码来源:CacheConfiguration.java

示例8: cacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager() {
    log.debug("Starting Ehcache");
    cacheManager = net.sf.ehcache.CacheManager.create();
    cacheManager.getConfiguration().setMaxBytesLocalHeap(env.getProperty("cache.ehcache.maxBytesLocalHeap", String.class, "16M"));
    log.debug("Registring Ehcache Metrics gauges");
    Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities();
    for (EntityType<?> entity : entities) {
        
        String name = entity.getName();
        if ( name == null ) {
            name = entity.getJavaType().getName();
        }
        Assert.notNull(name, "entity cannot exist without a identifier");
        
        net.sf.ehcache.Cache cache = cacheManager.getCache(name);
        if (cache != null) {
            cache.getCacheConfiguration().setTimeToLiveSeconds(env.getProperty("cache.timeToLiveSeconds", Integer.class, 3600));
            net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache);
            cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache);
        }
    }
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);
    return ehCacheManager;
}
 
开发者ID:exteso,项目名称:parkingfriends,代码行数:27,代码来源:CacheConfiguration.java

示例9: cacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Ehcache");
    cacheManager = net.sf.ehcache.CacheManager.create();
    cacheManager.getConfiguration().setMaxBytesLocalHeap(jHipsterProperties.getCache().getEhcache().getMaxBytesLocalHeap());
    log.debug("Registering Ehcache Metrics gauges");
    Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities();
    for (EntityType<?> entity : entities) {

        String name = entity.getName();
        if (name == null || entity.getJavaType() != null) {
            name = entity.getJavaType().getName();
        }
        Assert.notNull(name, "entity cannot exist without a identifier");

        net.sf.ehcache.Cache cache = cacheManager.getCache(name);
        if (cache != null) {
            cache.getCacheConfiguration().setTimeToLiveSeconds(jHipsterProperties.getCache().getTimeToLiveSeconds());
            net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache);
            cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache);
        }
    }

    // Cache for KML content in KmlService
    Cache kmlCache = new Cache(new net.sf.ehcache.config.CacheConfiguration("kml", 0));
    kmlCache.setName("kml");
    kmlCache.getCacheConfiguration().setEternal(true);
    kmlCache.setBootstrapCacheLoader(bootstrapCacheLoader);

    cacheManager.addCache(kmlCache);
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);

    return ehCacheManager;
}
 
开发者ID:jbernach,项目名称:transandalus-backend,代码行数:36,代码来源:CacheConfiguration.java

示例10: cacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Bean
public CacheManager cacheManager(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Ehcache");
    cacheManager = net.sf.ehcache.CacheManager.create();
    cacheManager.getConfiguration().setMaxBytesLocalHeap(jHipsterProperties.getCache().getEhcache().getMaxBytesLocalHeap());
    log.debug("Registering Ehcache Metrics gauges");
    Stream.of(cacheManager.getCacheNames()).forEach(name -> {
        net.sf.ehcache.Cache cache = cacheManager.getCache(name);
        cacheManager.replaceCacheWithDecoratedCache(cache, InstrumentedEhcache.instrument(metricRegistry, cache));
    });
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);
    return ehCacheManager;
}
 
开发者ID:stormpath,项目名称:generator-jhipster-stormpath,代码行数:15,代码来源:CacheConfiguration.java

示例11: ehcacheCacheWithCaches

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Test
public void ehcacheCacheWithCaches() {
	load(DefaultCacheConfiguration.class, "spring.cache.type=ehcache");
	EhCacheCacheManager cacheManager = validateCacheManager(
			EhCacheCacheManager.class);
	assertThat(cacheManager.getCacheNames()).containsOnly("cacheTest1", "cacheTest2");
	assertThat(this.context.getBean(net.sf.ehcache.CacheManager.class))
			.isEqualTo(cacheManager.getCacheManager());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:CacheAutoConfigurationTests.java

示例12: ehcacheCacheWithConfig

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Test
public void ehcacheCacheWithConfig() {
	load(DefaultCacheConfiguration.class, "spring.cache.type=ehcache",
			"spring.cache.ehcache.config=cache/ehcache-override.xml");
	EhCacheCacheManager cacheManager = validateCacheManager(
			EhCacheCacheManager.class);
	assertThat(cacheManager.getCacheNames()).containsOnly("cacheOverrideTest1",
			"cacheOverrideTest2");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:CacheAutoConfigurationTests.java

示例13: ehcacheCacheWithExistingCacheManager

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Test
public void ehcacheCacheWithExistingCacheManager() {
	load(EhCacheCustomCacheManager.class, "spring.cache.type=ehcache");
	EhCacheCacheManager cacheManager = validateCacheManager(
			EhCacheCacheManager.class);
	assertThat(cacheManager.getCacheManager())
			.isEqualTo(this.context.getBean("customEhCacheCacheManager"));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:CacheAutoConfigurationTests.java

示例14: ehCacheCacheWithCaches

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Test
public void ehCacheCacheWithCaches() {
	load(DefaultCacheConfiguration.class, "spring.cache.type=ehcache");
	EhCacheCacheManager cacheManager = validateCacheManager(
			EhCacheCacheManager.class);
	assertThat(cacheManager.getCacheNames()).containsOnly("cacheTest1", "cacheTest2");
	assertThat(this.context.getBean(net.sf.ehcache.CacheManager.class))
			.isEqualTo(cacheManager.getCacheManager());
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:10,代码来源:CacheAutoConfigurationTests.java

示例15: ehCacheCacheWithConfig

import org.springframework.cache.ehcache.EhCacheCacheManager; //导入依赖的package包/类
@Test
public void ehCacheCacheWithConfig() {
	load(DefaultCacheConfiguration.class, "spring.cache.type=ehcache",
			"spring.cache.ehcache.config=cache/ehcache-override.xml");
	EhCacheCacheManager cacheManager = validateCacheManager(
			EhCacheCacheManager.class);
	assertThat(cacheManager.getCacheNames()).containsOnly("cacheOverrideTest1",
			"cacheOverrideTest2");
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:10,代码来源:CacheAutoConfigurationTests.java


注:本文中的org.springframework.cache.ehcache.EhCacheCacheManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。