• 工作中遇到的问题--缓存配置(使用@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;
    }
    }

  • 相关阅读:
    机器码call和jmp地址的计算
    linux下系统对于sigsegv错误时的处理
    elf文件中的.plt .rel.dyn .rel.plt .got .got.plt的关系
    docker随谈
    nginx性能优化技巧
    ubuntu安装php常见错误集锦
    ubuntu php5.6源码安装
    关于mysqld_safe
    ubuntu mysql5.7源码安装
    linux下nginx模块开发入门
  • 原文地址:https://www.cnblogs.com/ly-radiata/p/4981222.html
Copyright © 2020-2023  润新知