MxScreen/Session/Medium/Raw_File.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 59 CC 4 SCAR 15.5
CC
4
Cov
0%
_store_locked
12.0
_retrieve_locked
6.0
BEGIN
2.0
CRAP 4.7
1 # -*- Mode: perl -*-
2 #
3 # $Id: Raw_File.pm,v 0.1 2001/04/22 17:57:04 ram Exp $
4 #
5 # Copyright (c) 1998-2001, Raphael Manfredi
6 # Copyright (c) 2000-2001, Christophe Dehaudt
7 #
8 # You may redistribute only under the terms of the Artistic License,
9 # as specified in the README file that comes with the distribution.
10 #
11 # HISTORY
12 # $Log: Raw_File.pm,v $
13 # Revision 0.1 2001/04/22 17:57:04 ram
14 # Baseline for first Alpha release.
15 #
16 # $EndLog$
17 #
18  
19 use strict;
20  
21 package CGI::MxScreen::Session::Medium::Raw_File;
22  
23 #
24 # Session storage is a file, via raw Storable access.
25 #
26  
27 require CGI::MxScreen::Session::Medium::File;
28 use vars qw(@ISA);
29 @ISA = qw(CGI::MxScreen::Session::Medium::File);
30  
31 use Carp::Datum;
32 use Getargs::Long;
33 use Log::Agent;
34 use Fcntl;
35  
36 #
37 # ->_retrieve_locked -- redefined
38 #
39 # retrieve context from (locked) file.
40 #
41 sub _retrieve_locked {
42 DFEATURE my $f_;
43 my $self = shift;
44 my ($path) = @_;
45  
46 require Storable;
47  
48 my $ref = Storable::retrieve($path);
49 logerr "unable to retrieve from session file $path" unless defined $ref;
50  
51 return DVAL $ref;
52 }
53  
54 #
55 # ->_store_locked -- redefined
56 #
57 # Store context into (locked) file.
58 #
59 sub _store_locked {
60 DFEATURE my $f_;
61 my $self = shift;
62 my ($path, $context) = @_;
63  
64 require Storable;
65  
66 my $ok = $self->shared ?
67 Storable::nstore($context, $path) :
68 Storable::store($context, $path);
69  
70 logerr "unable to save into session file $path" unless defined $ok;
71  
72 return DVOID;
73 }
74  
75 1;
76  
77 =head1 NAME
78  
79 CGI::MxScreen::Session::Medium::Raw_File - Fast file session medium
80  
81 =head1 SYNOPSIS
82  
83 # Not meant to be used directly
84  
85 =head1 DESCRIPTION
86  
87 This class behaves exactly as C<CGI::MxScreen::Session::Medium::File>
88 excepted that it ignores the serializer configuration and hardwires
89 C<Storable>, which allows for efficient storage and retrieval
90 since the C<Storable> routines C<store()> and C<retrieve()>
91 are used directly on files.
92  
93 This means that there's no compression of the serialized context,
94 but the aim here is performance.
95  
96 Please refer to L<CGI::MxScreen::Session::Medium::File> for the creation
97 routine interface.
98  
99 You can configure this session medium in the configuration file as
100 explained in L<CGI::MxScreen::Config> by saying:
101  
102 $mx_medium = ["+Raw_File", -directory => "/var/tmp/www-sessions"];
103  
104 This is the settings I use on my own web server.
105  
106 =head1 AUTHOR
107  
108 Raphael Manfredi F<E<lt>Raphael_Manfredi@pobox.comE<gt>>
109  
110 =head1 SEE ALSO
111  
112 CGI::MxScreen::Session::Medium::Browser(3),
113 CGI::MxScreen::Session::Medium::File(3).
114  
115 =cut
116