Hi Marco,
There are a number of issues that need to be seperated and dealt with on their own merits.
- How to retrieve the to be cached data.
- Where to store the cached data.
- How to update the cached data.
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).
Business/Domain Java Object.
Session bean (stateful)
Each method has their pro�s & con�s.
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.
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.
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
