• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to cache data from datasource

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a number of tables in my datasource, where the contents of some of the fields will not change (the fields in question essentially enforce constraints on data entry into related tables). Rather than do endless round trips to the database, I would like to cache this information while WebSpahere starts, as opposed to loading the cache when a service that relies on the cached data is invoked for the first time.

Can you suggest pointers on this?

I've looked at extending the CacheableCommandImpl class to acheive this, but I think that this still relies on an initial invocation - I want the server to load this data at start-up. Once it's cached I'll need to write an application layer interface to retrieve this static data.

Any help would be gratefully received.
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Write a singleton static object that keeps the data in memory. This assumes the data does not change and there's not an extremely large amount of it. Most of the solutions WebSphere provides are too IBM dependent to be of much use. You could also bind the data to a JNDI object although this isn't the best for performance.

I recommend caching solutions that load the data when it is first requested but then saved for the life of the server.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic