| 1 | package Apache::Session::Store::CacheAny; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 8 | my($class, $session) = @_; | |||||||||||||||||||||||||||
| 10 | 8 | bless { cache => undef }, $class; | |||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 6 | ▶ | sub insert { | ||||||||||||||||||||||||||
|
Subroutine
insert: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 6 | my($self, $session) = @_; | |||||||||||||||||||||||||||
| 15 | 6 | my $cache = $self->_cache($session); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | if ($cache->get_object($session->{data}->{_session_id})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 0 | die "Object already exists in the data store."; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 4 | $cache->set($session->{data}->{_session_id} => $session->{serialized}); | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | sub update { | ||||||||||||||||||||||||||
|
Subroutine
update: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 2 | my($self, $session) = @_; | |||||||||||||||||||||||||||
| 26 | 2 | my $cache = $self->_cache($session); | |||||||||||||||||||||||||||
| 27 | 2 | $cache->set($session->{data}->{_session_id} => $session->{serialized}); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 3 | ▶ | sub materialize { | ||||||||||||||||||||||||||
|
Subroutine
materialize: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | 3 | my($self, $session) = @_; | |||||||||||||||||||||||||||
| 32 | 3 | my $cache = $self->_cache($session); | |||||||||||||||||||||||||||
| 33 | $session->{serialized} = $cache->get($session->{data}->{_session_id}) | ||||||||||||||||||||||||||||
| 34 | 3 | ▶ | or die "Object does not exist in data store."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub remove { | ||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | 0 | my($self, $session) = @_; | |||||||||||||||||||||||||||
| 39 | 0 | $self->_cache($session)->remove($session->{data}->{_session_id}); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 11 | ▶ | sub _cache { | ||||||||||||||||||||||||||
|
Subroutine
_cache: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 43 | 11 | my($self, $session) = @_; | |||||||||||||||||||||||||||
| 44 | 11 | ▶ | unless ($self->{cache}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | # Tries to load implementation | ||||||||||||||||||||||||||||
| 46 | # We ignore "Can't locate" exception | ||||||||||||||||||||||||||||
| 47 | 9 | my $impl = $session->{args}->{CacheImpl}; | |||||||||||||||||||||||||||
| 48 | 9 | eval qq{require $impl}; | |||||||||||||||||||||||||||
| 49 | 9 | ▶ | if ($@ && !$impl->can('new')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ and not $impl->can("new")
MC/DC50%1/2
$@ and not $impl->can("new")
$@
not $impl->can("new")
Truth table66%2/3
A and not(B)
A= $@B= not $impl->can("new")
| |||||||||||||||||||||||||||||
| 50 | 2 | die "Failed to load $impl: $@"; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # Different named parameter style here | ||||||||||||||||||||||||||||
| 54 | 7 | 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 | my %opt = map { | ||||||||||||||||||||||||||||
| 67 | 7 | exists $session->{args}->{$_} ? | |||||||||||||||||||||||||||
| 68 | 63 | ▶ | ($arg2opt{$_} => $session->{args}->{$_}) : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | } keys %arg2opt; | ||||||||||||||||||||||||||||
| 70 | 7 | $self->{cache} = $impl->new(\%opt); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | 9 | $self->{cache}; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 6 | 1; | |||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||