Hi Luie,
 

 > How to retrieve the to be cached data would have meaning to your design strategy. Ie. How you implemented  your  >data  > retrieval logic. 
 > You can have the cache as an;
 > Entity bean (BMP or CMP). 

 
Yes, current one used BMP entity beans (poorly implemented....)

 One design pattern suggested was the weblogic 'read-mostly' design pattern.

But that data needs ONLY to be read by my application, so using an EJB for reading data is a little expense.

I can use Session bean (stateful), but what about  updating it? the database is updated from another application, so in my

application how should i detect it? i should find a way to tell to my application 'ok, now re-read the data in the database..

Business/Domain Java Object. 

Do u have any example on that?

 > Each method has their pro’s & con’s. 

true, that's what i am trying to figure out.... ;-) 

 > Where you want to store or keep your cache is the next point to consider. It is generally agreed that closer to the  > Client Tier the better. This aids in performance and limits network bandwidth usage. I would tend to agree with this  > idea for read only data that changes infrequently. The more frequent the changes to the cached data the further  > back you would want to keep your cache, while adding appropriate logic to refresh the cache. Of course if you  > are using entity beans then the refresh mechanism is implicit. 

Not in the current 'poor implementation'. Ideally, teh data should be read when u issue 'findByPrimaryKey', but that method does not read data at all.

Indeed, only one Entity bean is used for the whole application, since it reads all the data from the DB at once.

How to update the cache in a ‘smart’ fashion could be achieved by using the ‘Evictor’ pattern. This is basically a cache with a mechanism to re-fresh itself based on some rules.

Evictor pattern documentation:
www.cs.wustl.edu/~mk1/Evictor.pdf
http://www2.iona.com/MinervaRoot/index.jsp?action=article&catId=_100314&articleURL=/support/articles/2169.800.xml
Advanced CORBA programming with C++ by Michi Henning & Steve Vinoski
The ‘TAO’ Framework (free ORB is based on) uses the Evictor pattern, check it’s documentation & code.

I cannot give you a definitive answer to your question, as there will be many issues to consider.

 > Basically have the cache (array of services for the different coutries) sitting on your JSP/Servlet engine as a java  > object (singleton). How it gets it from the Business tier (ejb container is up to you). Allow the evictor object to  > refresh this cache at predetermined values. A cache manager Servlet could be used to retrieve from the cache. 

and thus i have to provide my servlet a method that is called ONLY when i want to refresh the cache, right?

What about using JDO?

If i retrieve all the objects with a query within the same transaction (initiated when the servlet is initialized, and ended when the servlet 'exits'), if i am

correct every change in the database will be reflected in the objects retrieved by the query. Is that correct?

If yes, that would solve my  problems...

Anyone can add his/her comments??

 

thanx and regards

    marco

 

 

 

Hope I understood your issue and that the above explanation makes sense.

Cheers Luie

*************************************************

thanx 4 the suggestion, but it may not be completed for me... problem is that i have to manage users from different countries. each country has a predefined set of services available, so all the users that logs in from the same country should have all the same services available.

Now every some time the availability of those services change, because some changes are made in the database using another tool. It is not practical, as i said, to cache all the services in HttpSession, since i will have still to call the bean 1 time for every user that logs in.

I have read the pattern that u mentioned me, but the issue is that i have to specify a read-timeout, and neither this is pratical:

i have to have control over the time in which the bean data is refreshed, 'coz it may happens that one day the database is changed every hours, and some days it is changed 1 time per day, so i cannot set a fixed timeout: - if i set it once per day and the change is done in the afternoon, i have to wait the next day to see changes (which is not acceptable) - if i set it once per hour, it can be a waste of time in days in which the database data never changes. do u have any alternative solutions to suggest me? i was thinking about a Stateful Session bean that is used for updating and reading data... but i am not sure if it will work. Do u have any other suggestion to give me? thanx in advance and

regards marco



Yahoo! Messenger for SMS - Now send & receive IMs on your mobile via SMS

Reply via email to