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