Re: cache a object in modperl

Wesley Peng <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
That's great. Thank you Adam.

Adam Prime wrote:
> If the database doesn't change very often, and you don't mind only 
> getting updates to your database when you restart apache, and you're 
> using prefork mod_perl, then you could use a startup.pl to load your 
> database before apache forks, and get a shared copy globally in all your 
> apache children.
> 
> https://perl.apache.org/docs/1.0/guide/config.html#The_Startup_File
> 
> This thread from 13 years ago seems to have a clear-ish example of how 
> to use startup.pl to do what i'm talking about.
> 
> If you need it to update more frequently than when you restart apache, 
> you could potentially use a PerlChildInitHandler to load the data when 
> apache creates children.  This will use more memory, as each child will 
> have it's own copy, and can also result in situation where children can 
> have different versions of the database loaded and be serving requests 
> at the same time.  If you want to go this way you might want to also add 
> a MaxRequestsPerChild directive to your apache config to make sure that 
> you're children die and get refreshed on the regular, if you don't 
> already have one.
> 
> Adam
> 
> 
> On 9/13/2020 10:51 PM, Wesley Peng wrote:
>> Hello
>>
>> I am not so familiar with modperl.
>>
>> For work requirement, I need to access IANA TLD database.
>>
>> So I wrote this perl module:
>> https://metacpan.org/pod/Net::IANA::TLD
>>
>> But, for each new() in the module, the database file will be 
>> downloaded from IANA's website.
>>
>> I know this is pretty Inefficient.
>>
>> My question is, can I cache the new'ed object by modperl?
>>
>> If so, how to do?
>>
>> Thanks.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.