Last active
June 29, 2018 05:13
Revisions
-
davetownsend revised this gist
Jul 23, 2014 . No changes.There are no files selected for viewing
-
davetownsend revised this gist
Jul 23, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,7 +48,7 @@ private CacheConfiguration cacheConfig(String name, long maxEntries) { Make sure to add the following gradle dependencies: compile 'org.springframework:spring-context-support:4.0.6.RELEASE' compile 'net.sf.ehcache:ehcache:2.8.3' If you use maven you'll just have figure it out. -
davetownsend revised this gist
Jul 23, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,8 +48,7 @@ private CacheConfiguration cacheConfig(String name, long maxEntries) { Make sure to add the following gradle dependencies: compile "org.springframework:spring-context-support:4.0.6.RELEASE" compile 'net.sf.ehcache:ehcache:2.8.3' If you use maven you'll just have figure it out. -
davetownsend created this gist
Jul 23, 2014 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ package org.dt.cachetest; import net.sf.ehcache.config.CacheConfiguration; import org.springframework.cache.annotation.CachingConfigurer; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.ehcache.EhCacheCacheManager; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.cache.interceptor.SimpleKeyGenerator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration @EnableCaching @ComponentScan("org.dt.cachetest") public class EhCacheConfig implements CachingConfigurer { final static String CACHE_POLICY = "LRU"; @Bean(destroyMethod = "shutdown") public net.sf.ehcache.CacheManager ehCacheManager() { net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration(); config.addCache(cacheConfig("cache1", 500)); config.addCache(cacheConfig("cache2", 500)); return net.sf.ehcache.CacheManager.newInstance(config); } @Bean @Override public org.springframework.cache.CacheManager cacheManager() { return new EhCacheCacheManager(ehCacheManager()); } @Bean @Override public KeyGenerator keyGenerator() { return new SimpleKeyGenerator(); } private CacheConfiguration cacheConfig(String name, long maxEntries) { CacheConfiguration config = new CacheConfiguration(); config.setName(name); config.setMaxEntriesLocalHeap(maxEntries); config.setMemoryStoreEvictionPolicy(CACHE_POLICY); return config; } } Make sure to add the following gradle dependencies: ``` compile "org.springframework:spring-context-support:4.0.6.RELEASE" compile 'net.sf.ehcache:ehcache:2.8.3' ``` If you use maven you'll just have figure it out.