line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Cache::Backend; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
140593
|
use strict; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
54
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
922
|
use Class::Utils qw(set_params); |
|
2
|
|
|
|
|
25597
|
|
|
2
|
|
|
|
|
41
|
|
7
|
2
|
|
|
2
|
|
140
|
use Error::Pure qw(err); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
72
|
|
8
|
2
|
|
|
2
|
|
11
|
use List::Util qw(none); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
79
|
|
9
|
2
|
|
|
2
|
|
11
|
use Readonly; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
795
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Readonly::Array our @TYPES => qw(description label); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.01; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
|
|
0
|
0
|
|
my ($class, @params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Create object. |
19
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Process parameters. |
22
|
0
|
|
|
|
|
|
set_params($self, @params); |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get { |
28
|
0
|
|
|
0
|
0
|
|
my ($self, $type, $key) = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Check type. |
31
|
0
|
|
|
|
|
|
$self->_check_type($type); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $self->_get($type, $key); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub save { |
37
|
0
|
|
|
0
|
0
|
|
my ($self, $type, $key, $value) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Check type. |
40
|
0
|
|
|
|
|
|
$self->_check_type($type); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $self->_save($type, $key, $value); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _check_type { |
46
|
0
|
|
|
0
|
|
|
my ($self, $type) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if (! defined $type) { |
49
|
0
|
|
|
|
|
|
err 'Type must be defined.'; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
0
|
|
0
|
|
|
if (none { $type eq $_ } @TYPES) { |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
err "Type '$type' isn't supported."; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _get { |
59
|
0
|
|
|
0
|
|
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
err "This is abstract class. You need to implement '_get' method."; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _save { |
65
|
0
|
|
|
0
|
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
err "This is abstract class. You need to implement '_save' method."; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |