工作中遇到的问题--缓存配置(使用@Configuration装配 @Bean的方式注入)
@EnableCaching
@Configuration
public class MFGCachingConfiguration {
@Autowired
private MFGSettings mfgSettings;
@Bean(name="MFGKeyGenerator")
public KeyGenerator MFGKeyGenerator(){
SimpleKeyGenerator defaultKeyGen = new SimpleKeyGenerator();
KeyGenerator mfgKeyGen = new KeyGenerator(){
@Override
public Object generate(Object target, Method method, Object... params) {
if(method != null){
return method.getName() + defaultKeyGen.generate(target, method, params);
} else {
return defaultKeyGen.generate(target, method, params);
}
}
};
return mfgKeyGen;
}
@Bean
public CacheManager getEhCacheManager() {
CacheConfiguration ehCacheConf = new CacheConfiguration();
ehCacheConf.setName("dashboard_cache");
ehCacheConf.setMaxEntriesLocalDisk(1000l);
ehCacheConf.setMaxEntriesLocalHeap(5000l);
ehCacheConf.setEternal(false);
ehCacheConf.setDiskSpoolBufferSizeMB(50);
int dashboardCacheCleanUpSchedulerFrequency = Integer.parseInt(mfgSettings.getDashboardCacheCleanUpSchedulerFrequency());
ehCacheConf.setTimeToIdleSeconds(dashboardCacheCleanUpSchedulerFrequency);
ehCacheConf.setTimeToLiveSeconds(dashboardCacheCleanUpSchedulerFrequency);
ehCacheConf.setMemoryStoreEvictionPolicy("LFU");
ehCacheConf.setTransactionalMode("OFF");
ehCacheConf.addPersistence(new PersistenceConfiguration().strategy(Strategy.LOCALTEMPSWAP));
net.sf.ehcache.config.Configuration configration = new net.sf.ehcache.config.Configuration();
configration.setName("dashboard_cache");
configration.addCache(ehCacheConf);
CacheManager cacheManager = new EhCacheCacheManager(new net.sf.ehcache.CacheManager(configration));
return cacheManager;
}
}
最新文章
- 51Nod 1010 只包含因子2 3 5的数 Label:None
- Instant Complexity - POJ1472
- zkw费用流+当前弧优化
- 在CentOS上部署基于dnx/coreclr的ASP.NET 5应用程序
- 解决PL/SQL查询结果乱码的问题
- __proto__
- 人生导师——如何学习C++的Windows方向
- Mysql 数据库安装配置
- css3之gradient
- zf-关于通知公告显示问题
- VB.Net隐式转换和显式转换的方法(转)
- LeetCode 1. Two Sum (两数之和)
- Ueditor1.3.6 setContent的一个bug
- Spring MVC 以.html为后缀名访问获取数据,报406 Not Acceptable错误
- 【python】__import__
- 为什么要使用NoSQL
- 使用Nginx转发TCP/UDP数据
- Fix Backup Database is terminating abnormally When performing a Farm Backup
- ubuntu ftp 建立匿名用户 [转]
- 【记录】cygwin下折腾个人配置环境