本文整理汇总了Java中org.springframework.cache.ehcache.EhCacheCacheManager.setCacheManager方法的典型用法代码示例。如果您正苦于以下问题:Java EhCacheCacheManager.setCacheManager方法的具体用法?Java EhCacheCacheManager.setCacheManager怎么用?Java EhCacheCacheManager.setCacheManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.cache.ehcache.EhCacheCacheManager
的用法示例。
在下文中一共展示了EhCacheCacheManager.setCacheManager方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例4: 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;
}
示例5: 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;
}
示例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.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;
}
示例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.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;
}
示例8: 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;
}
示例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");
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;
}
示例10: cacheManager
import org.springframework.cache.ehcache.EhCacheCacheManager; //导入方法依赖的package包/类
@Bean
public CacheManager cacheManager() {
EhCacheCacheManager ehCacheCacheManager = new EhCacheCacheManager();
ehCacheCacheManager
.setCacheManager(ehCacheManagerFactoryBean().getObject());
return ehCacheCacheManager;
}
示例11: springCacheManager
import org.springframework.cache.ehcache.EhCacheCacheManager; //导入方法依赖的package包/类
@Bean
public CacheManager springCacheManager() {
log.debug("Starting Spring Cache");
EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
ehCacheManager.setCacheManager(cacheManager);
return ehCacheManager;
}
示例12: cacheManager
import org.springframework.cache.ehcache.EhCacheCacheManager; //导入方法依赖的package包/类
@Bean
public CacheManager cacheManager() {
if (cacheManager != null) {
log.debug("Skipping creation of EHcache manager - already exists");
} else {
log.debug("Starting Ehcache");
net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
net.sf.ehcache.config.CacheConfiguration cacheConfiguration = new net.sf.ehcache.config.CacheConfiguration().maxElementsInMemory(1600);
config.setDefaultCacheConfiguration(cacheConfiguration);
cacheManager = net.sf.ehcache.CacheManager.create(config);
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", Integer.class, 3600));
net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache);
cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache);
}
}
ehCacheManager = new EhCacheCacheManager();
ehCacheManager.setCacheManager(cacheManager);
}
return ehCacheManager;
}
示例13: springCacheManager
import org.springframework.cache.ehcache.EhCacheCacheManager; //导入方法依赖的package包/类
@Bean
public CacheManager springCacheManager() {
log.debug("Starting Spring Cache");
net.sf.ehcache.CacheManager cacheManager = cacheManagerFactory().getObject();
EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
ehCacheManager.setCacheManager(cacheManager);
String[] cacheNames = cacheManager.getCacheNames();
for (String cacheName : cacheNames) {
Cache cache = cacheManager.getCache(cacheName);
cacheManager.replaceCacheWithDecoratedCache(cache, InstrumentedEhcache.instrument(metricRegistry, cache));
}
return ehCacheManager;
}
示例14: cacheManager
import org.springframework.cache.ehcache.EhCacheCacheManager; //导入方法依赖的package包/类
@Bean
public CacheManager cacheManager(EhCacheManagerFactoryBean ehCacheManagerFactoryBean) {
EhCacheCacheManager ehCacheCacheManager = new EhCacheCacheManager();
ehCacheCacheManager.setCacheManager(ehCacheManagerFactoryBean.getObject());
return ehCacheCacheManager;
}