Ok so the situation is this:

I have a simple perl script that does processes on files and is run from cron, this script reads a configuration file passed to it from command line.

#!/usr/bin/perl -w use strict; use vars qw($file); $file = $ARGV[0]; open(CONF,$file) || die("$!: $file"); while(<CONF>) { ... code for parsing and storing config ... } close(CONF); ... more code for doing other stuff ...

I have yet another perl program, however it is not a script it is a package used as a handler for a mod_perl enabled apache web server with an apache configuration directive such as this ...

PerlModule My::Package::Foo; <Location /foohandler> SetHandler perl-script PerlHandler My::Package::Foo; PerlSetVar FooConfig /some/patch/config.cfg </Location>

Now as you can see there is a PerlSetVar that is the path of a config file, this would be the same config file that the perl script running from cron uses. It is very important that these they read the same config.

So its simple enough for me to use the same config file parser in the handler as I am inside of the perl script running from cron.

package My::Package::Foo; sub handler { my($r) = shift; my($file) = $r->dir_config('FooConfig'); open(CONF,$file) || die("$!: $file"); while(<CONF>) { ... same code for parsing stuff as before ... } close(CONF); ... more code for doing other stuff ... }

Ah! but it would much faster if I cached the data in the config file inside of apache, instead of re-reading/parsing that config file for every request.

So question one is... what is the best method of caching data inside of apache like so?

And question two is... if I define another location directive that has the same handler would these two handler's share that cached data or would they be in seperate memory space inside of apache, and if they are in the same space whats the best way to seperate them?

ever delusional

-lindex
I know I should rtfm :)




lindex
/****************************/ jason@gost.net, wh@ckz.org http://jason.gost.net /*****************************/

In reply to Storing data with mod_perl (are those handlers different) ? by lindex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.