Re: Server Level Global Variable

Michael Ludwig <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <20100413193735.GB2548@wladimir>
Shibi NS schrieb am 13.04.2010 um 23:53:18 (+0530):
[Server Level Global Variable]

> I have requirement to maintain variables at server level say
> a counter(something like server restart count) variable and
> time date

So you're aware of Apache2::ServerUtil#restart_count ?

> so if particular event(say die on request handler) this
> counter increments by one and time date variable updated to
> current system date and time.  Is there is any way to do it
> so all request process get access to this variable can be
> updated by  Apache reques

Well, I'm a bit surprised I can't find anything that looks
like it's intended for this very purpose, but if you scroll
through the perldoc for Apache2::ServerRec and get to the
"Unsupported API" section, you'll see "names" and
"wild_names", both of which could possibly *abused* to serve
your needs. Here's a registry script:

         \,,,/
         (o o)
-----oOOo-(_)-oOOo-----
use common::sense;
use Apache2::Const ();
use Apache2::ServerRec ();
use Data::Dumper;

my $r = shift;
my $s = $r->server;
my $ap_names  = $s->names;
my $ap_wnames = $s->wild_names;

$r->content_type('text/plain');
$r->print( Dumper $ap_names, $ap_wnames );
return Apache2::Const::OK;
-----------------------

The output is:

$VAR1 = bless( do{\(my $o = 136268856)}, 'APR::ArrayHeader' );
$VAR2 = bless( do{\(my $o = 136268896)}, 'APR::ArrayHeader' );

But I don't know how to continue: there's no interface to the
APR::ArrayHeader structure. So this won't work. And it would have
been a hack anyway.

You could consider using memcached or a similar mechanism. But
I agree Apache should have something to offer here. After all,
Apache's emphasis isn't on being lean and mean. Well, maybe I
just don't know where to look.

-- 
Michael Ludwig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.