Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading config options from mySQL 1

Status
Not open for further replies.

SPrelewicz

Programmer
Jul 16, 2001
124
US
Using:
mySQL
CGI::Applicaion
CGI::Session

Im going to load some app config options from a mySQL table and store them in a session. Using CGI::Application for the whole thing. Can someone suggest a way to access all the options, store them in the session. If the session exists, obviously I dont want or need to call the db again. Should I have accessor methods for all of them? Or load them all in one function then have accessor methods off of that? Thanks.
 
Either way is a perfectly valid approach, I switch between 'whole config' and 'getter/setter' methods depending on the applications size and complexity. When using perl I tend to not use getter/setter out of habit and return things like config's as hashrefs to requesting member functions.

Keep in mind, saving 'database hits' can be an illusion if your using a DB backed session store. Sure, you don't have to go back to the mysql table for the options on every click but you are going back to the db to get the mysql options from the session store, something that actually has more overhead then a single call since your transforming the data on the way and the session can be larger from a dataset perspective then the original call you were making.

I've used sessions extensively and also written apps that are sessionless. Generally I have found that the less you use the session (if its db backed) the faster your app will run. This is a general statement, obviously every system is different.

The important thing to remember is that modern rdms are optimized around fast queries. If you design your schema correctly you won't be hurt by proper queries very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top