Reputation: 29
I am trying to use ehcache cache. For two different user my webservice creates different cache which is acting like session. Can i create single cache which will work same as context concept
Upvotes: 1
Views: 1869
Reputation: 451
When instantiating an EhCache CacheManager (which is the first step in getting a reference to a Cache object) you have several options per EhCache APIs:
Since you haven't provided any detail on your implementation, I can only suppose that you are (knowingly or not) creating a new CacheManager object (http://ehcache.org/apidocs/net/sf/ehcache/CacheManager.html) per service request or session...and that would explain the behavior you're noticing.
If you were using the singleton concept for creating the CacheManager (method 2), you would indeed create a single CacheManager + get a single reference to a Cache object that can be access accross threads (requests, sessions, etc ...)
Upvotes: 1