John Drago wrote:
Hi,

Say hypothetically that I want a certain block of code to run every 5
minutes.

Would I...
        a) fork() off a child process in a script loaded up with a
PerlRequire directive in the httpd.conf?

        b) Use $r->register_cleanup(...) to handle the fork()ing and all
that? (kludgy because of forking off a whole new server process)

        c) Simply use a cron job to execute a different script? (But how
would I get the Apache::ASP objects? [$Server/$Session/$Application])

        d) Use a cron job to execute code that sends an http request to
an ASP page on the server? (Even though this works great, it seems wrong
somehow).


I would advocate (d), because something as precise as needing something done every 5 minutes falls in the domain of cron. Then just running an lwp-request against a URL is trivial.

Alternatively, if you just want to cache something for 5 minutes, the
the $Response->Include({ Cache => 1, ... }) API and cache an includes
output for 300 seconds.  Includes can return cached data for example.
In this one, one may cache an expensive calculation, just by wrapping
it up in an include.  For the cache API, check out:

http://www.apache-asp.org/objects.html#%24Response-%3EIa3beea1e

Note, use caching prudently.  Its as slow as the CacheDB access layer,
so should only be used for expensive calculations, say those that take
longer than .005-.01 seconds to run. ( machine dependent of course ).
Using a MLDBM::Sync::SDBM_File layer can be as fast as .002 seconds to fetch
smaller bits of data.  DB_File and GDBM_File can be slower but scale better
to larger data sets.

Regards,

Josh
________________________________________________________________________
Josh Chamas, Founder    | NodeWorks - http://www.nodeworks.com
Chamas Enterprises Inc. | NodeWorks Directory - http://dir.nodeworks.com
http://www.chamas.com   | Apache::ASP - http://www.apache-asp.org



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to