| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Sman::Man::Cache::FileCache; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#$Id$ |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
826
|
use Cache::FileCache; |
|
|
1
|
|
|
|
|
27582
|
|
|
|
1
|
|
|
|
|
40
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use base 'Sman::Man::Cache'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
379
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use fields qw( filecache ); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
3
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# pass a dir to store the cache data in |
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
1
|
|
|
1
|
0
|
555
|
my $class = shift; |
|
13
|
1
|
|
|
|
|
2
|
my $dir = shift; |
|
14
|
1
|
|
|
|
|
2
|
my $self = fields::new($class); |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
2398
|
$self->SUPER::new(); # init base fields |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
50
|
|
|
|
2
|
if (defined($dir)) { |
|
19
|
0
|
|
|
|
|
0
|
my %hash = ( 'namespace' => 'sman', 'default_expires_in' => "1 month" ); |
|
20
|
0
|
|
|
|
|
0
|
$^W=0; # avoid pseudo-hash warnings on perl 5.8.0 |
|
21
|
0
|
|
|
|
|
0
|
$self->{filecache} = new Cache::FileCache( \%hash ); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
1
|
|
|
|
|
2
|
return $self; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub get { |
|
27
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
28
|
0
|
|
|
|
|
|
my $key = shift; |
|
29
|
0
|
|
|
|
|
|
my $val; |
|
30
|
|
|
|
|
|
|
#local $^W = 0; # hide 'pseudo-hashes are deprecated' warnings in perl 5.8.0 |
|
31
|
1
|
|
|
1
|
|
108
|
no warnings; # hide 'pseudo-hashes are deprecated' warnings in perl 5.8.0 |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
71
|
|
|
32
|
0
|
0
|
0
|
|
|
|
if (defined($self->{filecache}) && ($val = $self->{filecache}->get($key) ) ) { |
|
33
|
0
|
|
|
|
|
|
return $val; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
0
|
|
|
|
|
|
return undef; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
sub set { |
|
38
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
39
|
0
|
|
|
|
|
|
my $key = shift; |
|
40
|
|
|
|
|
|
|
# we handle rawdata right from $_[0]. Why not? |
|
41
|
|
|
|
|
|
|
#local $^W = 0; # hide 'pseudo-hashes are deprecated' warnings in perl 5.8.0 |
|
42
|
1
|
|
|
1
|
|
3
|
no warnings; # hide 'pseudo-hashes are deprecated' warnings in perl 5.8.0 |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
73
|
|
|
43
|
0
|
0
|
|
|
|
|
$self->{filecache}->set($key, $_[0]) if ($self->{filecache}); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
sub Clear { |
|
46
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
47
|
0
|
|
|
|
|
|
my $cache = $self->{filecache}; |
|
48
|
0
|
0
|
|
|
|
|
defined($cache) && ($cache->Clear()); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Sman::Man::Cache::FileCache - Cache converted manpages in a Cache::FileCache |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# this module is intended for internal use by sman-update |
|
60
|
|
|
|
|
|
|
my $cache = new Sman::Man::Cache::FileCache(); |
|
61
|
|
|
|
|
|
|
$cache->set("/usr/man/man3/ls.3", "some stuff"); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# ..later... |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $ret = $cache->get("/usr/man/man3/ps.3"); |
|
66
|
|
|
|
|
|
|
# $ret will be undef if data not found. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Uses a Cache::FileCache to store raw data for use by Sman::Man::Convert. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AUTHOR |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Josh Rabinowitz |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L, L, L, L |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |