Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caching in an EJB container

 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem in figuring out how to do some caching of reference data.
We are developing a clustered app (using WebLogic 6.1 SP5) which requires data to be cached on the server. The data is produced by five DAO classes which retrieve data from the DB and return the reference data as an array. The idea is to then run the SQL queries daily and, if there is a discrepancy with the cache, to overwrite any or all of the five cached arrays with the new data. Oh, we are also going to store a timestamp for each cached array.
A stateless session bean is going to be the user (reader) of the cached data.
Now, storing the arrays in the DB is possible but ruled out by our tech lead who does not wish to make any changes to the DB at this stage of the project. We've agreed that memory caching would be fine, but how can I do it in a way that does not violate the EJB 2.0 spec? I can't use in my bean non-final static variables, and I can't serialize to file even if I wanted to.
I'm not sure whether it's a good idea to cache in a singleton class, as I don't know how you can guarantee that you really do have a singleton in a container.
Any ideas gratefully received ...
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle's recent article in our newsletter might be of interest to you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic