Created
March 30, 2014 21:00
-
-
Save steveash/9879696 to your computer and use it in GitHub Desktop.
Sample ehcache manager bean factory
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 characters
@org.springframework.context.annotation.Configuration | |
public class CacheBeans { | |
private static final AtomicInteger cacheCounter = new AtomicInteger(0); | |
@Bean | |
public EhCacheManagerFactoryBean ecmfb() { | |
EhCacheManagerFactoryBean ecmfb = new EhCacheManagerFactoryBean(); | |
// cannot share the cache managers | |
ecmfb.setShared(false); | |
// if you are using ehcache.xml on the classpath then there's nothing more to do than just make it | |
// a unique name. If you are using a different config file then use ecmfb.setConfigLocation() | |
ecmfb.setCacheManagerName("ehCache-" + cacheCounter.incrementAndGet()); | |
return ecmfb; | |
} | |
// more @Bean defs | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment