The only global variable I'm using is AUTOLOAD. I'm coding in OO style and using inheritance. I'm using AUTOLOAD for more flexibility in my object structures.
package Entities::Entity;
our $AUTOLOAD;
use constant UNDEF_VALUE => '##UNDEF_VALUE##';
sub new() {
my ($class) = @_;
my $self = {
};
bless $self, $class;
return $self;
}
sub AUTOLOAD {
my ($self, $val) = @_;
my $type = ref($self) or croak "$self is not an object";
my $name = $AUTOLOAD;
$name =~ s/.*://; # strip fully-qualified portion
if (defined($val)) {
if ($val eq UNDEF_VALUE) {
$self->{$name} = undef;
} else {
return $self->{$name} = $val;
}
} else {
my $val = $self->{$name};
$self->{$name} = undef unless (defined($val));
if (ref($val) eq "HASH") {
return \%$val;
}
if (ref($val) eq "ARRAY") {
return \@$val;
}
return $val;
}
}
package Customer::Entities::CustomerInvoice;
use base qw(Entities::Entity);
sub new {
my ($class) = @_;
my $self = $class->SUPER::new();
return $self;
}
On the other hand, everytime a new request comes in, new objects are created. If the member's values were cached, nothing would work properly I guess.
Also, my debug messages show that each object is different.
On the database end, the only package level global variable is a hash holding the database handles.
I do not do any explicit caching. There is also no cached queries in mysql.
I was suspecting apache/modperl to do some transparent query result caching for long running queries. Could it be the case ? (for info, I'm running ActivePerl 5.10, Apache 2.2, XP SP2).
I thought I would try to look into apache's memory and see what objects are still in cache after a request but I cannot find a repository for the B-Size module. Any idea where to find this ? (probably different topic)
Thanks
|