| Bryce Harrington 2005-11-26, 6:55 pm |
| On Sat, Nov 26, 2005 at 09:47:33PM +0800, He Nan wrote:
> In my script there is a external C programme , I have to call it every time
> when the script runs .
> But the C programme needs to load big dictionary , the time consuming is
> more than 5 seconds .
> What should I do to make it more efficient , could I modify the C programme
> so that when it runs for the first time , the dictionary is loaded into the
> memory and never free until service is shutdown , or shall I try mod_perl to
> write a module in c ? I'm , for I'm a beginner to CGI programming .
Have you looked at CGI::Fast ? It permits persistence like mod_perl,
but is easier to set up and configure.
I've just begun playing with it myself for caching the DB hash for a
Perl-based online game, but it's doing well so far.
For you, CGI::Fast should allow you to keep the dictionary in memory
between invocations.
Another technique I've used is to run the C program as a daemon process,
and then connect to it through a socket from your perl program when you
need to do operations. But that's probably overkill for your case...
Bryce
|