On 22 Oct 2017 23:15, André Warnier (tomcat) wrote:
On 22.10.2017 18:59, John Dunlap wrote:
In our case, we do not use Windows for anything. Even our desktops are
Linux. We already
employ Redis, which performs the same function as memcache, however,
this doesn't really
solve the problem because each virtualhost also relies on its own redis
database so, even
in that case, we would still need a per virtualhost configuration
mechanism to tell us
which redis database to use.
At present, I kinda like Ben Rubson's suggestion of a read only hash in
a startup script
which is keyed by hostname
Yes, no doubt about that. But this does not answer the question : where
do you store this hash (or a reference to it), so that a handler, later,
would have access to it ?
startup_script :
my $big_hash = {
hostname1 => { ... },
hostname2 => { ... },
};
# save $big_hash "somewhere"
exit;
... later ...
sub handler {
# how do I access $big_hash ? (where is it ?)
return OK;
}
You can use Startup.pm like this :
package Startup;
use strict;
use warnings;
use base qw(Exporter);
our @EXPORT_OK = qw(%config);
our %config;
$config{'VH1'}{'foo'} = 'nicevalue';
1;
Then in your other scripts :
use Startup qw(%config);
my $var = $config{'VH1'}{'foo'};
Or without a package, if your vars are rather simple, you could use $ENV...
Ben