Apache-XPP
view release on metacpan or search on metacpan
lib/Apache/XPP/Cache/Store/File.pm view on Meta::CPAN
} # END method cachedir
=item C<content> ( [ \$content ] )
Sets the store object's content to $content and returns TRUE.
If $content is omitted, returns the content of the store object.
=cut
sub content {
my $self = shift;
my $class = ref($self) || return undef;
my $filename = $self->filename;
if (my $content = shift) {
my $fh = new FileHandle ("> $filename");
return undef unless ((defined $fh) && (ref($content)));
print $fh ${ $content };
$fh->close;
return 1;
} else {
my $fh = new FileHandle ($filename);
return undef unless (defined $fh);
local($/) = undef;
return <$fh>;
}
} # END method content
=item C<is_expired> ( )
Removes the store file.
=cut
sub is_expired {
my $self = shift;
my $class = ref($self) || return undef;
my $filename = $self->filename;
unlink $filename || warn "file\t: cannot delete file ($filename): $!" . ($debuglines ? '' : "\n");
return 1;
} # END method is_expired
=item C<mtime> ( )
=item C<mtime> ( $name, $group )
Returns the modification time of the specified store.
=cut
sub mtime {
my $proto = shift;
my $filename;
if (my $class = ref($proto)) {
$filename = $proto->filename;
} else {
my $name = shift;
my $group = shift;
$filename = $proto->location( $name, $group );
}
my $st = stat($filename); # using File::stat
unless (ref($st) && $st->can('mtime')) {
warn "file:\tcannot stat file ($filename): $!" . ($debuglines ? '' : "\n") if ($debug);
return undef;
}
return $st->mtime;
} # END method mtime
1;
__END__
=back
=head1 REVISION HISTORY
$Log: File.pm,v $
Revision 1.9 2002/01/16 21:06:01 kasei
Updated VERSION variables to 2.01
Revision 1.8 2002/01/15 07:34:22 kasei
From: Pierre Phaneuf <pp@ludusdesign.com>
Subject: [Xpp-general] small warning fix
Date: Mon, 14 Jan 2002 21:51:10 -0500
Message-Id: <3C43991E.571FAC9E@ludusdesign.com>
Fixes regex range warning.
Revision 1.7 2000/09/13 21:00:52 dougw
Small change to line 165.
Revision 1.6 2000/09/11 20:12:23 david
Various minor code efficiency improvements.
Revision 1.5 2000/09/07 19:01:57 dougw
Pod fixin's
=head1 AUTHORS
Greg Williams <greg@cnation.com>
=head1 SEE ALSO
perl(1).
Apache::XPP
Apache::XPP:Cache
=cut
( run in 0.663 second using v1.01-cache-2.11-cpan-5735350b133 )