line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Cache; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
146825
|
use strict; |
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
943
|
use Class::Utils qw(set_params); |
|
2
|
|
|
|
|
25934
|
|
|
2
|
|
|
|
|
43
|
|
7
|
2
|
|
|
2
|
|
129
|
use English; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
15
|
|
8
|
2
|
|
|
2
|
|
897
|
use Error::Pure qw(err); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
585
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.01; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
0
|
|
my ($class, @params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Create object. |
16
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
$self->{'backend'} = 'Basic'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Process parameters. |
21
|
0
|
|
|
|
|
|
set_params($self, @params); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Load backend module. |
24
|
0
|
|
|
|
|
|
my $backend_module = 'Wikibase::Cache::Backend::'.$self->{'backend'}; |
25
|
0
|
|
|
|
|
|
eval "require $backend_module;"; |
26
|
0
|
0
|
|
|
|
|
if ($EVAL_ERROR) { |
27
|
0
|
|
|
|
|
|
err "Cannot load module '$backend_module'.", |
28
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
$self->{'_backend'} = $backend_module->new; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub get { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, $type, $key) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return $self->{'_backend'}->get($type, $key); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub save { |
42
|
0
|
|
|
0
|
0
|
|
my ($self, $type, $key, $value) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return $self->{'_backend'}->save($type, $key, $value); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |