--- axkit.orig/lib/Apache/AxKit/Cache.pm 2003-06-18 14:11:56.000000000 +0000 +++ axkit/lib/Apache/AxKit/Cache.pm 2006-02-07 23:03:35.130795728 +0000 @@ -16,78 +16,76 @@ sub new { my $class = shift; - my ($r, $xmlfile, @extras) = @_; - - my $gzip = 0; + my $apache = shift; + my ($xmlfile, @extras) = @_; + + my $self = bless { apache => $apache }, $class; + + $self->{gzip} = 0; if ($xmlfile =~ /\.gzip/) { - $gzip++; + ++$self->{gzip}; # @extras = grep(!/gzip/, @extras); } +# $self->{extras} = \@extras; +# warn "New for: $xmlfile:" . join(':', @extras). "\n"; + + $self->{dir} = $AxKit::Cfg->CacheDir(); + $self->{no_cache} = $AxKit::Cfg->NoCache() ? 1 : undef; + if (my $alternate = $AxKit::Cfg->CacheModule()) { + AxKit::Debug(8, "Cache Override: $alternate" ); + AxKit::reconsecrate($self, $alternate); + } + + $self->init(@_); + +# AxKit::Debug(7, "Cache->new Count: ".++$COUNT); + + return $self; +} + +sub init { + my $self = shift; + my ($xmlfile, @extras) = @_; local $^W; # suppress "Use of uninitialized value" warnings - my $key = Digest::MD5->new->add( + $self->{key} = Digest::MD5->new->add( join(':', - $r->hostname, - $r->get_server_port, + $self->{apache}->hostname, + $self->{apache}->get_server_port, $xmlfile, @extras ))->hexdigest; - AxKit::Debug(7, "Cache: key = $key"); - - my $primary = substr($key,0,2,''); - my $secondary = substr($key,0,2,''); - -# warn "New for: $xmlfile:" . join(':', @extras). "\n"; - - my $cachedir = $AxKit::Cfg->CacheDir(); - - my $no_cache; + AxKit::Debug(7, "Cache: key = $self->{key}"); - if ($AxKit::Cfg->NoCache()) { - $no_cache = 1; - } + my $primary = substr($self->{key},0,2,''); + my $secondary = substr($self->{key},0,2,''); - if (!$no_cache) { + my $cachedir = $self->{dir}; + if (!$self->{no_cache}) { if (!-e $cachedir) { if (!mkdir($cachedir, 0777)) { AxKit::Debug(2, "Can't create cache directory '$cachedir': $!"); - $no_cache = 1; + $self->{no_cache} = 1; } } if (!-e "$cachedir/$primary") { if (!mkdir("$cachedir/$primary", 0777)) { AxKit::Debug(1, "Can't create cache directory '$cachedir/$primary': $!"); - $no_cache = 1; + $self->{no_cache} = 1; } } if (!-e "$cachedir/$primary/$secondary") { if (!mkdir("$cachedir/$primary/$secondary", 0777)) { AxKit::Debug(1, "Can't create cache directory '$cachedir/$primary/$secondary': $!"); - $no_cache = 1; + $self->{no_cache} = 1; } } } - my $self = bless { - apache => $r, - key => $key, - no_cache => $no_cache, - dir => $cachedir, - file => "$cachedir/$primary/$secondary/$key", - gzip => $gzip, -# extras => \@extras, - }, $class; - - if (my $alternate = $AxKit::Cfg->CacheModule()) { - AxKit::reconsecrate($self, $alternate); - } - -# AxKit::Debug(7, "Cache->new Count: ".++$COUNT); - - return $self; + $self->{file} = "$cachedir/$primary/$secondary/$self->{key}"; } sub _get_stats {