line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# --------------------------------------------------------- |
2
|
|
|
|
|
|
|
# This code is largely based on DeWitt Clinton's |
3
|
|
|
|
|
|
|
# Cache::MemoryCache. It relies upon the fact that we have |
4
|
|
|
|
|
|
|
# ferreted out the calls to Clone_Data(). |
5
|
|
|
|
|
|
|
# --------------------------------------------------------- |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Cache::FastMemoryCache; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5698
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
55
|
|
10
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
11
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
64
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.01; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use base qw ( Cache::BaseCache ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1027
|
|
16
|
1
|
|
|
1
|
|
29825
|
use Cache::CacheUtils qw( Assert_Defined Static_Params ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
66
|
|
17
|
1
|
|
|
1
|
|
677
|
use Cache::FastMemoryBackend; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
401
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub Clear |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
0
|
1
|
0
|
foreach my $namespace ( _Namespaces( ) ) |
23
|
|
|
|
|
|
|
{ |
24
|
0
|
|
|
|
|
0
|
_Get_Backend( )->delete_namespace( $namespace ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub Purge |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
0
|
1
|
0
|
foreach my $namespace ( _Namespaces( ) ) |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
|
|
0
|
_Get_Cache( $namespace )->purge( ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub Size |
39
|
|
|
|
|
|
|
{ |
40
|
0
|
|
|
0
|
1
|
0
|
my $size = 0; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
foreach my $namespace ( _Namespaces( ) ) |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
|
|
0
|
$size += _Get_Cache( $namespace )->size( ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
return $size; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _Get_Backend |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
|
0
|
return new Cache::MemoryBackend( ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _Namespaces |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
0
|
|
0
|
return _Get_Backend( )->get_namespaces( ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _Get_Cache |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
0
|
|
0
|
my ( $p_namespace ) = Static_Params( @_ ); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
Assert_Defined( $p_namespace ); |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
0
|
return new Cache::MemoryCache( { 'namespace' => $p_namespace } ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub new |
74
|
|
|
|
|
|
|
{ |
75
|
2
|
|
|
2
|
1
|
194
|
my ( $self ) = _new( @_ ); |
76
|
|
|
|
|
|
|
|
77
|
2
|
|
|
|
|
19
|
$self->_complete_initialization( ); |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
|
|
34
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _new |
83
|
|
|
|
|
|
|
{ |
84
|
2
|
|
|
2
|
|
4
|
my ( $proto, $p_options_hash_ref ) = @_; |
85
|
2
|
|
33
|
|
|
12
|
my $class = ref( $proto ) || $proto; |
86
|
2
|
|
|
|
|
18
|
my $self = $class->SUPER::_new( $p_options_hash_ref ); |
87
|
2
|
|
|
|
|
224
|
$self->_set_backend( new Cache::FastMemoryBackend( ) ); |
88
|
2
|
|
|
|
|
47
|
return $self; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub set_object |
93
|
|
|
|
|
|
|
{ |
94
|
1
|
|
|
1
|
1
|
216
|
my ( $self, $p_key, $p_object ) = @_; |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
2
|
my $object = $p_object; # no clone |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
4
|
$object->set_size( undef ); |
99
|
1
|
|
|
|
|
7
|
$object->set_key( undef ); |
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
10
|
$self->_get_backend( )->store( $self->get_namespace( ), $p_key, $object ); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
__END__ |