| Sman documentation | Contained in the Sman distribution. |
Sman::Man::Cache::FileCache - Cache converted manpages in a Cache::FileCache
# this module is intended for internal use by sman-update
my $cache = new Sman::Man::Cache::FileCache();
$cache->set("/usr/man/man3/ls.3", "some stuff");
# ..later...
my $ret = $cache->get("/usr/man/man3/ps.3");
# $ret will be undef if data not found.
Uses a Cache::FileCache to store raw data for use by Sman::Man::Convert.
Josh Rabinowitz <joshr>
sman-update, Sman::Man::Convert, sman.conf, Sman::Man::Cache
| Sman documentation | Contained in the Sman distribution. |
package Sman::Man::Cache::FileCache; #$Id: FileCache.pm,v 1.7 2006/02/27 02:07:19 joshr Exp $ use Cache::FileCache; use base 'Sman::Man::Cache'; use fields qw( filecache ); # pass a dir to store the cache data in sub new { my $class = shift; my $dir = shift; my $self = fields::new($class); $self->SUPER::new(); # init base fields if (defined($dir)) { my %hash = ( 'namespace' => 'sman', 'default_expires_in' => "1 month" ); $^W=0; # avoid pseudo-hash warnings on perl 5.8.0 $self->{filecache} = new Cache::FileCache( \%hash ); } return $self; } sub get { my $self = shift; my $key = shift; my $val; #local $^W = 0; # hide 'pseudo-hashes are deprecated' warnings in perl 5.8.0 no warnings; # hide 'pseudo-hashes are deprecated' warnings in perl 5.8.0 if (defined($self->{filecache}) && ($val = $self->{filecache}->get($key) ) ) { return $val; } return undef; } sub set { my $self = shift; my $key = shift; # we handle rawdata right from $_[0]. Why not? #local $^W = 0; # hide 'pseudo-hashes are deprecated' warnings in perl 5.8.0 no warnings; # hide 'pseudo-hashes are deprecated' warnings in perl 5.8.0 $self->{filecache}->set($key, $_[0]) if ($self->{filecache}); } sub Clear { my $self = shift; my $cache = $self->{filecache}; defined($cache) && ($cache->Clear()); } 1;