line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###################################################################### |
2
|
|
|
|
|
|
|
# $Id: MemoryBackend.pm,v 1.10 2003/01/16 18:10:16 dclinton Exp $ |
3
|
|
|
|
|
|
|
# Copyright (C) 2001-2003 DeWitt Clinton 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::MemoryBackend; |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
71
|
|
14
|
2
|
|
|
2
|
|
7
|
use Cache::CacheUtils qw( Clone_Data ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
856
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $Store_Ref = { }; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new |
21
|
|
|
|
|
|
|
{ |
22
|
68
|
|
|
68
|
0
|
105
|
my ( $proto ) = @_; |
23
|
68
|
|
33
|
|
|
259
|
my $class = ref( $proto ) || $proto; |
24
|
68
|
|
|
|
|
93
|
my $self = {}; |
25
|
68
|
|
|
|
|
146
|
$self = bless( $self, $class ); |
26
|
68
|
|
|
|
|
124
|
$self->_initialize_memory_backend( ); |
27
|
68
|
|
|
|
|
237
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub delete_key |
32
|
|
|
|
|
|
|
{ |
33
|
27
|
|
|
27
|
0
|
46
|
my ( $self, $p_namespace, $p_key ) = @_; |
34
|
|
|
|
|
|
|
|
35
|
27
|
|
|
|
|
52
|
delete $self->_get_store_ref( )->{ $p_namespace }{ $p_key }; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub delete_namespace |
40
|
|
|
|
|
|
|
{ |
41
|
25
|
|
|
25
|
0
|
81
|
my ( $self, $p_namespace ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
25
|
|
|
|
|
52
|
delete $self->_get_store_ref( )->{ $p_namespace }; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_keys |
48
|
|
|
|
|
|
|
{ |
49
|
47
|
|
|
47
|
0
|
90
|
my ( $self, $p_namespace ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
47
|
|
|
|
|
58
|
return keys %{ $self->_get_store_ref( )->{ $p_namespace } }; |
|
47
|
|
|
|
|
112
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_namespaces |
56
|
|
|
|
|
|
|
{ |
57
|
36
|
|
|
36
|
0
|
44
|
my ( $self ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
36
|
|
|
|
|
37
|
return keys %{ $self->_get_store_ref( ) }; |
|
36
|
|
|
|
|
70
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub get_size |
64
|
|
|
|
|
|
|
{ |
65
|
119
|
|
|
119
|
0
|
148
|
my ( $self, $p_namespace, $p_key ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
119
|
50
|
|
|
|
193
|
if ( exists $self->_get_store_ref( )->{ $p_namespace }{ $p_key } ) |
68
|
|
|
|
|
|
|
{ |
69
|
119
|
|
|
|
|
187
|
return length $self->_get_store_ref( )->{ $p_namespace }{ $p_key }; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
|
|
0
|
return 0; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub restore |
79
|
|
|
|
|
|
|
{ |
80
|
122
|
|
|
122
|
0
|
137
|
my ( $self, $p_namespace, $p_key ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
122
|
|
|
|
|
249
|
return Clone_Data( $self->_get_store_ref( )->{ $p_namespace }{ $p_key } ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub store |
87
|
|
|
|
|
|
|
{ |
88
|
90
|
|
|
90
|
0
|
134
|
my ( $self, $p_namespace, $p_key, $p_data ) = @_; |
89
|
|
|
|
|
|
|
|
90
|
90
|
|
|
|
|
174
|
$self->_get_store_ref( )->{ $p_namespace }{ $p_key } = $p_data; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _initialize_memory_backend |
95
|
|
|
|
|
|
|
{ |
96
|
68
|
|
|
68
|
|
72
|
my ( $self ) = @_; |
97
|
|
|
|
|
|
|
|
98
|
68
|
50
|
|
|
|
108
|
if ( not defined $self->_get_store_ref( ) ) |
99
|
|
|
|
|
|
|
{ |
100
|
0
|
|
|
|
|
0
|
$self->_set_store_ref( { } ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _get_store_ref |
106
|
|
|
|
|
|
|
{ |
107
|
653
|
|
|
653
|
|
4291
|
return $Store_Ref; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _set_store_ref |
112
|
|
|
|
|
|
|
{ |
113
|
0
|
|
|
0
|
|
|
my ( $self, $p_store_ref ) = @_; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$Store_Ref = $p_store_ref; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |