line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###################################################################### |
2
|
|
|
|
|
|
|
# $Id: YAMLBackend.pm,v 1.3 2005/10/27 19:00:20 nachbaur Exp $ |
3
|
|
|
|
|
|
|
# Copyright (C) 2005 Michael Nachbaur All Rights Reserved |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Software distributed under the License is distributed on an "AS |
6
|
|
|
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or |
7
|
|
|
|
|
|
|
# implied. See the License for the specific language governing |
8
|
|
|
|
|
|
|
# rights and limitations under the License. |
9
|
|
|
|
|
|
|
###################################################################### |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Cache::YAMLBackend; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
14
|
1
|
|
|
1
|
|
4
|
use vars qw( @ISA ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
15
|
1
|
|
|
1
|
|
4
|
use Cache::CacheUtils qw( Assert_Defined Build_Path ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
16
|
1
|
|
|
1
|
|
684
|
use YAML; |
|
1
|
|
|
|
|
7064
|
|
|
1
|
|
|
|
|
295
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
@ISA = qw( Cache::FileBackend ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _read_data { |
21
|
0
|
|
|
0
|
|
|
my $self = shift; |
22
|
0
|
|
|
|
|
|
my ($p_path) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
Assert_Defined($p_path); |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
my $frozen_data_ref = Cache::FileBackend::_Read_File_Without_Time_Modification($p_path) or |
27
|
|
|
|
|
|
|
return [ undef, undef ]; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $data_ref = eval { |
30
|
0
|
|
|
|
|
|
$self->_yaml->load($$frozen_data_ref); |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
0
|
|
|
|
if ($@ || (ref($data_ref) ne 'ARRAY')) { |
34
|
0
|
|
|
|
|
|
unlink Cache::FileBackend::_Untaint_Path($p_path); |
35
|
0
|
|
|
|
|
|
return [undef, undef]; |
36
|
|
|
|
|
|
|
} else { |
37
|
0
|
|
|
|
|
|
return $data_ref; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub store { |
42
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
return $self->SUPER::store(@_); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _write_data { |
47
|
0
|
|
|
0
|
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my ($self, $p_path, $p_data) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
Assert_Defined($p_path); |
51
|
0
|
|
|
|
|
|
Assert_Defined($p_data); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
Cache::FileBackend::_Make_Path($p_path, $self->get_directory_umask()); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $frozen_file = $self->_yaml->dump($p_data); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
Cache::FileBackend::_Write_File($p_path, \$frozen_file); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _yaml { |
61
|
0
|
|
|
0
|
|
|
my $self = shift; |
62
|
0
|
|
|
|
|
|
my $y = YAML->new; |
63
|
0
|
|
|
|
|
|
return $y; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |