Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-19 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found