Startup is not a great idea if your webserver is up forever - I have some
which are running for months.

How frequently do you wish to refresh the cache ? if you do in startup then
your cache refresh is tied to the service restart which might not be ideal
or feasible.

On Mon, Sep 14, 2020 at 12:26 AM Adam Prime <adam.pr...@utoronto.ca> wrote:

> I left out the link to the thread.  Here it is.
>
> https://marc.info/?t=119062870700002&r=1&w=2
>
>
>
> On Sep 14, 2020, at 1:18 AM, Wesley Peng <wp...@pobox.com> wrote:
>
> 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.
>
>

Reply via email to