Skip to content

Instantly share code, notes, and snippets.

@steveash
Created March 30, 2014 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveash/9879696 to your computer and use it in GitHub Desktop.
Save steveash/9879696 to your computer and use it in GitHub Desktop.
Sample ehcache manager bean factory
@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