You just need to name your keys more descriptively. Add part, or all, of the webservice name in the key, then a colon, and then the key and you should be fine.
get( webservice_name + ":" + id ); Let's do an experiment. Think of the cache as a hashtable. Say the elements never need to expire, you have unlimited memory, and you don't need to distribute any of the items, so a Hashtable is perfect for you. How would you use a hashtable or multiple hashtables? I suspect that you only need one hashtable. If so, then one region is fine. If it would work better by nesting hashtables, then use multiple regions. Either way, JCS will do the trick. One thing that jcs gives you is the ability to create new hastable of a sort and define the name on the fly. You could put JCS assessors in a hashtable and then get them out by some key indicating the webservice. Convieniently, the cache hub does something better for you and all you have to do is call getInstance with that unique key. New instances will take the default configuration values that you setup. Aaron > -----Original Message----- > From: Maarten Coene [mailto:[EMAIL PROTECTED]] > Sent: Friday, June 07, 2002 10:56 AM > To: Turbine JCS Users List > Subject: RE: More than 1 cache-instance [not] needed > > At 10:23 7/06/2002 -0400, you wrote: > >Why does the invoker need the cache? What does it do with it? > > The invoker is actually an interface to the webservice. If you want data > from the webservice, you ask the invoker to get this data and the invoker > creates the correct SOAP message and sends it to the webservice, retrieves > a SOAP response and converts it into specific objects. > > I give a simplified example: > > suppose you have webservices that provide a way to retrieve information > about persons (fictive example to illustrate things). The invoker could > look like this: > > public class PersonWebServiceInvoker { > > public PersonWebServiceInvoker(URL url) { > cache = JCS.getInstance("webservice"); > } > > public Person getPerson(String id) { > // create SOAP message, and transform the response to a Person > object > Person p = result-of-soap-message > cache.put(id, p); > return p; > } > > public boolean isPerson(String id) { > return getPerson(id) != null; > } > > ... > } > > >Why can't the webservice use the cache? > > I want to avoid the creation of the SOAPMessage, the network traffic, ... > Multiple calls of getPerson(id) with the same id shouldn't generate this > traffic. > > To illustrates the problem I'm dealing with: suppose I have to different > webservices (with different persons in it) > 1. retrieve a person with id1 from webservice1 > 2. the invoker is putting this person in its cache (region=webservice) > 3. execute the isPerson(id1) method in webservice2 > 4. normally, this should return false because that person doesn't exist in > webservice2, but in fact, it will return true because the invoker for > webservice2 will use the same cache is for webservice1 because the region > is the same (region=webservice). The same is true for getPerson(id): if I > execute getPerson(id1) on webservice2 after I executed getPerson(id1) on > webservice1, this method will return the same person I retrieved from > webservice1 since it is located in the cache. > > >You don't know the set of webservices? > > no. If a user finds a webservice that can understand the SOAP messages > like > we have specified, it should be possible that he adds this service (create > an invoker with the url of the service). > > how can I solve these problems? > > thanks, > Maarten > > > > -- > To unsubscribe, e-mail: <mailto:turbine-jcs-user- > [EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:turbine-jcs-user- > [EMAIL PROTECTED]>
