[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Ehcache CacheManager dilemma... ( newbie question )  XML
Forum Index -> Terracotta Licensing
Author Message


Joined: 01/23/2012 07:06:47
Messages: 14

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");

Whats difference between them?

My Spring DSL Service code is like that :

is it good to use it like this?

And what about Servlets , is it good to use
ThreadLocal CacheManager per Thread better ? or just singleton better solution for high performance?

Thanks for help now...



Joined: 12/13/2010 17:02:58
Messages: 13

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?
Forum Index -> Terracotta Licensing
Go to:   
Powered by JForum 2.1.7 © JForum Team