| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
WebService::Amazon::Route53::Caching::Store::DBM - DBM-based cache-storage. |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
This module implements several methods which makes it possible to |
|
9
|
|
|
|
|
|
|
get/set/delete cached values by a string-key. |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
The module will expect to be passed a filename to use for the cache in |
|
12
|
|
|
|
|
|
|
the constructor: |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=for example begin |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $redis = Redis->new(); |
|
17
|
|
|
|
|
|
|
my $cache = WebService::Amazon::Route53::Caching::Store::DBM->new( path => "/tmp/db.db" ); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=for example end |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Copyright (C) 2014 Steve Kemp <steve@steve.org.uk>. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This library is free software. You can modify and or distribute it under |
|
28
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
34
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
30
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
package WebService::Amazon::Route53::Caching::Store::DBM; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
304
|
use DB_File; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=begin doc |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Constructor. Save the filename away. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=end doc |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
|
|
|
|
|
|
my ( $proto, %supplied ) = (@_); |
|
55
|
|
|
|
|
|
|
my $class = ref($proto) || $proto; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $self = {}; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$self->{ '_path' } = $supplied{ 'path' }; |
|
60
|
|
|
|
|
|
|
bless( $self, $class ); |
|
61
|
|
|
|
|
|
|
return $self; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=begin doc |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Tie, set, and untie the backing-store. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=end doc |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub set |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
|
|
|
|
|
|
my ( $self, $key, $val ) = (@_); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my %h; |
|
84
|
|
|
|
|
|
|
tie %h, "DB_File", $self->{ '_path' }, O_RDWR | O_CREAT, 0666, $DB_HASH or |
|
85
|
|
|
|
|
|
|
return; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$h{ $key } = $val; |
|
88
|
|
|
|
|
|
|
untie(%h); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=begin doc |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Tie, get, and untie the backing-store. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=end doc |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub get |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
|
|
|
|
|
|
my ( $self, $key ) = (@_); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my %h; |
|
111
|
|
|
|
|
|
|
tie %h, "DB_File", $self->{ '_path' }, O_RDWR | O_CREAT, 0666, $DB_HASH or |
|
112
|
|
|
|
|
|
|
return; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $ret = $h{ $key }; |
|
115
|
|
|
|
|
|
|
untie(%h); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
return ($ret); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=begin doc |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Tie, unset, and untie the backing-store. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=end doc |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub del |
|
131
|
|
|
|
|
|
|
{ |
|
132
|
|
|
|
|
|
|
my ( $self, $key ) = (@_); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my %h; |
|
140
|
|
|
|
|
|
|
tie %h, "DB_File", $self->{ '_path' }, O_RDWR | O_CREAT, 0666, $DB_HASH or |
|
141
|
|
|
|
|
|
|
return; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$h{$key} = "[deleted]"; |
|
144
|
|
|
|
|
|
|
delete $h{ $key }; |
|
145
|
|
|
|
|
|
|
untie(%h); |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |
|
151
|
|
|
|
|
|
|
|