• Post Reply Bookmark Topic Watch Topic
  • New Topic

J2EE Caching of Remote Data

 
Jeff Ruschka
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me by pointing me in the right direction.

I'm looking for a J2EE design pattern that deals with caching data locally on the application server (app server currently is not using EJBs - just JDBC).

This data is in table form (rows and columns), only needs to be remotely retreived once a day because it changes so infrequently, but is accessed so frequently by the application that I'd like for it to be in memory and available to all users of the application.

Where is the best place for this to live ? application level (in a class?, properties file), user session level, in an xml file in a server dierctory ???

Trying to find a discussion of the pros and cons, and possibly alternative solutions.

Thanks in advance.
 
Damodar Periwal
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeff R:

Where is the best place for this to live ? application level (in a class?, properties file), user session level, in an xml file in a server dierctory ???


Since access is frequent, you may want to keep the data in the memory. So that rules out disk based solutions like properties and xml files unless the data volume is huge and memory size becomes a constraint.

Given that you want multiple users to access the data (perhaps simultaneously), you may want to keep the data in a hashtable whose access is synchronized by default. You could create a simple application level static public class (MyCache) something like the following:



Of course, you need to define a suitable class to hold your dataset(myData) and associate each instance with a key, i.e., a name to identify it. That way, you can have multiple instances of such datasets. If it makes it convenient to hold the dataset (rows) in business object instances, you may use an OR-Mapper to help you do that easily.

-- Damodar
Software Tree, Inc.
Simplify Data Integration
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!