@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;
}
}

最新文章

  1. 51Nod 1010 只包含因子2 3 5的数 Label:None
  2. Instant Complexity - POJ1472
  3. zkw费用流+当前弧优化
  4. 在CentOS上部署基于dnx/coreclr的ASP.NET 5应用程序
  5. 解决PL/SQL查询结果乱码的问题
  6. __proto__
  7. 人生导师——如何学习C++的Windows方向
  8. Mysql 数据库安装配置
  9. css3之gradient
  10. zf-关于通知公告显示问题
  11. VB.Net隐式转换和显式转换的方法(转)
  12. LeetCode 1. Two Sum (两数之和)
  13. Ueditor1.3.6 setContent的一个bug
  14. Spring MVC 以.html为后缀名访问获取数据,报406 Not Acceptable错误
  15. 【python】__import__
  16. 为什么要使用NoSQL
  17. 使用Nginx转发TCP/UDP数据
  18. Fix Backup Database is terminating abnormally When performing a Farm Backup
  19. ubuntu ftp 建立匿名用户 [转]
  20. 【记录】cygwin下折腾个人配置环境

热门文章

  1. Rhel6-集群管理(luci&&ricci)配置文档
  2. 蓝桥杯 algo——6 安慰奶牛 (最小生成树)
  3. ajax跨域相关
  4. 我们都遇到过的 Replace Blank Space
  5. Tengine安装配置
  6. 解决C#的64位打包程序,在64位机器上运行出现BadImageFormatException异常。
  7. C#获取项目程序及运行路径的方法
  8. (转)SQLLite数据操作
  9. Squid代理之透明代理
  10. PHP Filter