line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache::Session::Store::CacheAny; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
37
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
257
|
|
4
|
6
|
|
|
6
|
|
35
|
use vars qw($VERSION); |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
3413
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
8
|
|
|
8
|
0
|
18
|
my($class, $session) = @_; |
10
|
8
|
|
|
|
|
66
|
bless { cache => undef }, $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub insert { |
14
|
6
|
|
|
6
|
0
|
1862
|
my($self, $session) = @_; |
15
|
6
|
|
|
|
|
27
|
my $cache = $self->_cache($session); |
16
|
|
|
|
|
|
|
|
17
|
4
|
50
|
|
|
|
36
|
if ($cache->get_object($session->{data}->{_session_id})) { |
18
|
0
|
|
|
|
|
0
|
die "Object already exists in the data store."; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
475
|
$cache->set($session->{data}->{_session_id} => $session->{serialized}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub update { |
25
|
2
|
|
|
2
|
0
|
6130
|
my($self, $session) = @_; |
26
|
2
|
|
|
|
|
10
|
my $cache = $self->_cache($session); |
27
|
2
|
|
|
|
|
49
|
$cache->set($session->{data}->{_session_id} => $session->{serialized}); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub materialize { |
31
|
3
|
|
|
3
|
0
|
166
|
my($self, $session) = @_; |
32
|
3
|
|
|
|
|
12
|
my $cache = $self->_cache($session); |
33
|
3
|
100
|
|
|
|
33
|
$session->{serialized} = $cache->get($session->{data}->{_session_id}) |
34
|
|
|
|
|
|
|
or die "Object does not exist in data store."; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub remove { |
38
|
0
|
|
|
0
|
0
|
0
|
my($self, $session) = @_; |
39
|
0
|
|
|
|
|
0
|
$self->_cache($session)->remove($session->{data}->{_session_id}); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _cache { |
43
|
11
|
|
|
11
|
|
23
|
my($self, $session) = @_; |
44
|
11
|
100
|
|
|
|
57
|
unless ($self->{cache}) { |
45
|
|
|
|
|
|
|
# Tries to load implementation |
46
|
|
|
|
|
|
|
# We ignore "Can't locate" exception |
47
|
9
|
|
|
|
|
27
|
my $impl = $session->{args}->{CacheImpl}; |
48
|
9
|
|
|
|
|
1616
|
eval qq{require $impl}; |
49
|
9
|
100
|
66
|
|
|
106075
|
if ($@ && !$impl->can('new')) { |
50
|
2
|
|
|
|
|
62
|
die "Failed to load $impl: $@"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Different named parameter style here |
54
|
7
|
|
|
|
|
78
|
my %arg2opt = ( |
55
|
|
|
|
|
|
|
Namespace => 'namespace', |
56
|
|
|
|
|
|
|
DefaultExpiresIn => 'default_expires_in', |
57
|
|
|
|
|
|
|
AutoPurgeInterval => 'auto_purge_interval', |
58
|
|
|
|
|
|
|
AutoPurgeOnSet => 'auto_purge_on_set', |
59
|
|
|
|
|
|
|
AutoPurgeOnGet => 'auto_purge_on_get', |
60
|
|
|
|
|
|
|
MaxSize => 'max_size', |
61
|
|
|
|
|
|
|
CacheRoot => 'cache_root', |
62
|
|
|
|
|
|
|
CacheDepth => 'cache_depth', |
63
|
|
|
|
|
|
|
DirectoryUmask => 'directory_umask', |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
63
|
100
|
|
|
|
149
|
my %opt = map { |
67
|
7
|
|
|
|
|
31
|
exists $session->{args}->{$_} ? |
68
|
|
|
|
|
|
|
($arg2opt{$_} => $session->{args}->{$_}) : (); |
69
|
|
|
|
|
|
|
} keys %arg2opt; |
70
|
7
|
|
|
|
|
49
|
$self->{cache} = $impl->new(\%opt); |
71
|
|
|
|
|
|
|
} |
72
|
9
|
|
|
|
|
1628
|
$self->{cache}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |