Thank you.Sorry that module of Mymodule is a public module from CPAN.I can't modify it to add the init() and data() methods.
How to do it then?thanks again. -----Original Message----- From: suppressed To: suppressed CC: suppressed Sent: Tue, 25 Sep 2007 4.52PM Subject: Re: load large data suppressed wrote:
Thank you. I have added these directives in httpd.conf, > <Perl> use Mymodule; our $data = Mymodule->new; </Perl> > Then I run bin/apachectl configtest,but got the errors,> Unknown type 'Mymodule' for directive data at >
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Apache2/PerlSectio
ns.pm line 192.\n > Please help.Thanks.
As with all Perl code, there is more than one way to do it. Another way to accomplish what you are trying to do is through the use of startup.pl, which is run during apache startup. (I don't know why that error above is occurring so I'm posting this as an alternate approach).
# httpd.conf
PerlPostConfigRequire /home/pennyyh/perl/lib/startup.pl
# startup.pl
use strict;
use warnings;
use Mymodule;
Mymodule->init;
1;
## Mymodule.pm
package Mymodule;
use strict;
use warnings;
our $data;
sub new {
...
}
sub init {
my $class = shift;
$data = $class->new;
}
sub data {
my $class = shift;
return $data;
}
1;
then in your application you can access $data via $Mymodule::data, or
better yet access it like so:
my $data = Mymodule->data; # this returns the object created during # startup HTH, Fred
> > > -----Original Message----- From: suppressed To: suppressed CC: suppressed Sent: Tue, 25 Sep 2007 1.42AM Subject: Re: load large data > On Mon, 24 Sep 2007 06:08:45 -0400 suppressed wrote: >> Hello,I have a module,which loads large data into memory. my $data = Mymodule->new; this will take some ms to be finished. So I think I can create this object at startup time,and share the $data acrosss all apache child processes. Is it possible?How can I do it?> Yeah you can do this in a <Perl> section at startup and your children can then use it. I'm assuming here that the info in $data doesn't change or that you're ok with having to restart Apache to see the changes. > ------------------------------------------------------- Frank Wiles, Revolution Systems, LLC. Personal : suppressed http://www.wiles.org ; Work : suppressed http://www.revsys.com ;> > >
________________________________________________________________________
Check out the new free AOL Email -- 2GB of storage and
industry-leading > spam and email virus protection. ________________________________________________________________________Check out the new free AOL Email -- 2GB of storage and industry-leading spam and email virus protection.
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.