On Monday, 12 September 2011 13:03:30 utham hoode wrote:
> Here is the problem. Both path1 and path2 are sharing same global
> variable $param.Is there any way to avoid that?. Because In the
> actual proxy program I am reading aconfiguration file and storing it
> in a global variable. For path1 and path2 configuration file is
> different. I can place the variable inside sub handler {}so that for
> each request program loads the configuration file.I think this will
> reduce the performance.
how about
=httpd.conf=========================================
<LocationMatch "^/path1">
SetEnv CFG /path/to/config1.conf
</LocationMatch>
<LocationMatch "^/path2">
SetEnv CFG /path/to/config2.conf
</LocationMatch>
====================================================
=the handler========================================
my %config;
sub handler {
my ($r)=@_;
my $cfg=$r->subprocess_env->{CFG} or
die "No config file configured for ".$r->uri;
$cfg=($config{$cfg}||=read_cfg $cfg);
...
}
====================================================
Thus, the global %config is used as a cache for the configurations of the
various URIs. The actual file is read only on the first request.
All the configurations can even be pre-populated at startup time.
Note however, that since the config is read only once it can be changed
only by starting up a new interpreter. If that's a problem you can
monitor file modification times for example. If I were you I'd use an
MMapDB object.
Torsten Förtsch
--
Need professional modperl support? Hire me! (http://foertsch.name)
Like fantasy? http://kabatinte.net