Store/SharedMem.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 6 totaltotal 81.5% 31 / 38 CC 2 SCAR 2.1
CC
2
Cov
96%
materialize
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary SharedMem.pm »
1 # Apache::Session::Store::SharedMem
2  
3 # Copyright 2004, Simon Wistow <simon@thegestalt.org>
4 # This module is free software; you can redistribute it and/or
5 # modify it under the same terms as Perl itself.
6  
7 package Apache::Session::Store::SharedMem;
8  
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use IPC::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13  
14  
15 sub new
16 3 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
17 3 my ($class, $session) = shift;
18
19 3 my ($self, $cacheargs);
20
21  
22 3 $cacheargs->{namespace} = $session->{data}->{_session_id};
23 3 $cacheargs->{expires_in} = $session->{args}->{expires_in};
24  
25 3 $self->{cache} = new IPC::Cache ( $cacheargs );
26
27 3 return bless $self, $class;
28 }
29  
30 2 ▶sub insert {
Subroutine insert: called CC=1 SCAR=0.0
Pod undocumented
31  
32 2 my ($self, $session) = @_;
33
34 2 $self->{cache}->set($session->{data}->{_session_id}, $session->{serialized});
35 }
36  
37 1 ▶sub update {
Subroutine update: called CC=1 SCAR=0.0
Pod undocumented
38  
39 1 my ($self, $session) = @_;
40
41 1 $self->{cache}->set($session->{data}->{_session_id}, $session->{serialized});
42 }
43  
44 1 ▶sub materialize {
Subroutine materialize: called CC=2 SCAR=7.1
Pod undocumented
45 1 my ($self, $session) = @_;
46
47 1 $session->{serialized} = $self->{cache}->get($session->{data}->{_session_id});
48 1 ▶ return undef unless defined $session->{serialized};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $session->{"serialized"} 0 1 1
49  
50 }
51  
52 2 ▶sub remove {
Subroutine remove: called CC=1 SCAR=0.0
Pod undocumented
53  
54 2 my ($self, $session) = @_;
55
56
57 2 $self->{cache}->clear();
58
59 }
60  
61 2 ▶sub close {
Subroutine close: called CC=1 SCAR=0.0
Pod undocumented
62
63 }
64  
65  
66 1 1;
67  
68 =pod
69  
70 =head1 NAME
71  
72 Apache::Session::Store::SharedMem - Store persistent data in shared memory
73  
74 =head1 SYNOPSIS
75  
76  
77 use Apache::Session::Store::SharedMem;
78
79 my $store = new Apache::Session::Store::SharedMem;
80
81 $store->insert($ref);
82 $store->update($ref);
83 $store->materialize($ref);
84 $store->remove($ref);
85  
86 =head1 DESCRIPTION
87  
88 This module fulfills the storage interface of B<Apache::Session>. The serialized
89 objects are stored in shared memory.
90  
91 =head1 OPTIONS
92  
93 This module can optionally take one argument in the usual Apache::Session style.
94 The name of the option is B<expires_in>, and the value is the amount of time, in
95 seconds, that the data in the session will expire in.
96  
97  
98 # session wil expire in a day
99 tie %s, 'Apache::Session::SharedMem', undef, { expires_in => 86400 };
100  
101  
102 =head1 AUTHOR
103  
104 This module was written by Simon Wistow <simon@twoshortplanks.com>.
105  
106  
107 =head1 COPYRIGHT
108  
109 Copyright 2000, 2001 Simon Wistow <simon@twoshortplanks.com>
110 This module is free software; you can redistribute it and/or
111 modify it under the same terms as Perl itself.
112  
113 =head1 SEE ALSO
114  
115 L<Apache::Session>, L<Apache::Session::SharedMem>, L<IPC::Cache>
↑ Summary SharedMem.pm »