Hello I'm currently making new project on Spring DSL + Terracotta Ehcache
I am currently in dilemma now.
I've read sample codes on Ehcache ,
There are lots of CacheManager creation types:
1-) CacheManager manager = new CacheManager();
2-) CacheManager manager = CacheManager.getInstance();
3-) CacheManager manager = CacheManager.create();
4-) CacheManager manager = new CacheManager("ehcache.xml");
2 and 3 are doing the same
1 and 4 are the same (minus the path parameter)
all 4 are doing exactly the same except that 2 and 3 will use the singleton pattern to be sure you instantiate only once the CacheManager, while 1 and 4 will initialize the CacheManager every time.
so best advice is call 2 or 3 like you did.
1 and 4 would be more useful in the case where for some reason you want to handle the singleton by yourself
Glancing at your code, the Spring service looks ok to me except maybe the @Transactional annotation, but it's difficult to say without your Spring config, can you post it?