Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caching Java Properties

 
Chad Wessel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my web app, I have various scenarios where I read from Properties files to obtain information, such as JDBC pooling configurations, etc. Does anyone know of a clever way to load these properties files once and cache them, so that I won't have to hit the hard drive each time to obtain the the properties when they are needed?
Thanks in advance!
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I�ve never done this but I think you can create a class and populate it with final static fields representing your configurations and than you can acces its fields using NameOfClass.field this must be much faster than hiting the disk all the time.
I hope it helps.
 
Mike Burnham
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I load these into a static class for reference. In the logic to restart/refresh my application, I refresh these properties.
 
Chad Wessel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both for your replies... I'll give this a try and post my results. =)
Chad
 
spalaniv
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a Singleton object and store the properties as class data members.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic