I have an application where known users connect, and normally I do a db query to get their configuration information. What I would like to do is preload all of this information into memory, say into a global hash where all the mod perl processes can access it.
You want to use one of the many caching options. You should take a look at Cache::Cache or MLDBM::Sync. There are others as well. Personally, I use MLDBM::Sync (stores multi-level data structures in dbm files and allows for locking). MLDBM::Sync is implemented (as most of them are, I believe) as a tied hash so it works just about how you think it would.
If you wanted to truly preload it (i.e. at server startup time) you could write a bit of code in your mod_perl startup.pl file.
Perrin Harkins / Bill Hilf wrote a bit about this here: http://perl.apache.org/docs/tutorials/apps/scale_etoys/etoys.html
It has also be discussed on this list many time. Search the archives.
See also:
http://search.cpan.org/~chamas/MLDBM-Sync-0.30/Sync.pm http://search.cpan.org/~dclinton/Cache-Cache-1.02/lib/Cache/Cache.pm
(There are other modules that work equally well.)
And since the primary goal is making the program faster, any alternatives that would take longer than a database select wouldnt' do me any good.
Any DBM file or shared memory caching will be infinitely faster than making a DB round trip. There is usually some initial overhead during the initial fetch because it has to fetch the info from the rdbms and then write it to the cache, but it's trivial when you consider the benefits.
HTH. -- Eric Sammer [EMAIL PROTECTED] http://www.ineoconcepts.com
-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html