File Coverage

blib/lib/Apache/Session/Serialize/UUEncode.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 18 20 90.0


line stmt bran cond sub pod time code
1             #############################################################################
2             #
3             # Apache::Session::Serialize::UUEncode
4             # Serializes session objects using Storable and pack
5             # Copyright(c) 2000 Jeffrey William Baker (jwbaker@acm.org)
6             # Distribute under the Artistic License
7             #
8             ############################################################################
9              
10             package Apache::Session::Serialize::UUEncode;
11              
12 1     1   15 use strict;
  1         18  
  1         15  
13 1     1   15 use vars qw($VERSION);
  1         8  
  1         16  
14 1     1   16 use Storable qw(nfreeze thaw);
  1         9  
  1         21  
15              
16             $VERSION = '1.00';
17              
18             sub serialize {
19 1     1 0 360     my $session = shift;
20                 
21 1         22     $session->{serialized} = pack("u", nfreeze($session->{data}));
22             }
23              
24             sub unserialize {
25 1     1 0 10     my $session = shift;
26                 
27 1         43     $session->{data} = thaw(unpack("u", $session->{serialized}));
28             }
29              
30             1;
31              
32             =pod
33            
34             =head1 NAME
35            
36             Apache::Session::Serialize::UUEncode - Use Storable and C<pack()>
37             to zip up persistent data
38            
39             =head1 SYNOPSIS
40            
41             use Apache::Session::Serialize::UUEncode;
42            
43             $zipped = Apache::Session::Serialize::UUEncode::serialize($ref);
44             $ref = Apache::Session::Serialize::UUEncode::unserialize($zipped);
45            
46             =head1 DESCRIPTION
47            
48             This module fulfills the serialization interface of Apache::Session. It
49             serializes the data in the session object by use of Storable's C<nfreeze()> and
50             C<thaw()> functions, and Perl's C<pack()> and C<unpack()>. The serialized data
51             is ASCII text, suitable for storage in backing stores that don't handle binary
52             data gracefully, such as Postgres.
53            
54             =head1 AUTHOR
55            
56             This module was written by Jeffrey William Baker <jwbaker@acm.org>.
57            
58             =head1 SEE ALSO
59            
60             L<Apache::Session::Serialize::Storable>, L<Apache::Session::Serialize::Base64>,
61             L<Apache::Session>
62