http://www.perlmonks.org?node_id=70823
lindex has asked for the wisdom of the Perl Monks concerning the following question:

Ok so the situation is this:

I have a simple perl script that does processes on files and is run from cron, this script reads a configuration file passed to it from command line.

#!/usr/bin/perl -w use strict; use vars qw($file); $file = $ARGV[0]; open(CONF,$file) || die("$!: $file"); while(<CONF>) { ... code for parsing and storing config ... } close(CONF); ... more code for doing other stuff ...

I have yet another perl program, however it is not a script it is a package used as a handler for a mod_perl enabled apache web server with an apache configuration directive such as this ...

PerlModule My::Package::Foo; <Location /foohandler> SetHandler perl-script PerlHandler My::Package::Foo; PerlSetVar FooConfig /some/patch/config.cfg </Location>

Now as you can see there is a PerlSetVar that is the path of a config file, this would be the same config file that the perl script running from cron uses. It is very important that these they read the same config.

So its simple enough for me to use the same config file parser in the handler as I am inside of the perl script running from cron.

package My::Package::Foo; sub handler { my($r) = shift; my($file) = $r->dir_config('FooConfig'); open(CONF,$file) || die("$!: $file"); while(<CONF>) { ... same code for parsing stuff as before ... } close(CONF); ... more code for doing other stuff ... }

Ah! but it would much faster if I cached the data in the config file inside of apache, instead of re-reading/parsing that config file for every request.

So question one is... what is the best method of caching data inside of apache like so?

And question two is... if I define another location directive that has the same handler would these two handler's share that cached data or would they be in seperate memory space inside of apache, and if they are in the same space whats the best way to seperate them?

ever delusional

-lindex
I know I should rtfm :)




lindex
/****************************/ jason@gost.net, wh@ckz.org http://jason.gost.net /*****************************/