| 1 | ############################################################################# | ||
| 2 | # | ||
| 3 | # Apache::Session::Serialize::DBMS::YAML | ||
| 4 | # Serializes session objects using YAML and object-per-key support added | ||
| 5 | # for Apache::Session::DBMS module | ||
| 6 | # | ||
| 7 | # Copyright(c) 2005 Asemantics S.r.l. | ||
| 8 | # Alberto Reggiori (alberto@asemantics.com) | ||
| 9 | # Distribute under a BSD license (see LICENSE file in main dir) | ||
| 10 | # | ||
| 11 | ############################################################################ | ||
| 12 | |||
| 13 | package Apache::Session::Serialize::DBMS::YAML; | ||
| 14 | |||
| 15 | use strict; | ||
| 16 | use vars qw($VERSION); | ||
| 17 | use YAML (); | ||
| 18 | |||
| 19 | $VERSION = '0.1'; | ||
| 20 | |||
| 21 | sub serialize { | ||
| 22 | my $session = shift; | ||
| 23 | |||
| 24 | if( $session->{isObjectPerKey} ) { | ||
| 25 | YAML::Dump( shift ); | ||
| 26 | } else { | ||
| 27 | $session->{serialized} = YAML::Dump($session->{data}); | ||
| 28 | }; | ||
| 29 | }; | ||
| 30 | |||
| 31 | sub unserialize { | ||
| 32 | my $session = shift; | ||
| 33 | |||
| 34 | if( $session->{isObjectPerKey} ) { | ||
| 35 | YAML::Load( shift ); | ||
| 36 | } else { | ||
| 37 | $session->{data} = YAML::Load($session->{serialized}); | ||
| 38 | }; | ||
| 39 | }; | ||
| 40 | |||
| 41 | 1; | ||
| 42 | |||
| 43 | =pod | ||
| 44 | |||
| 45 | =head1 NAME | ||
| 46 | |||
| 47 | Apache::Session::Serialize::DBMS::YAML - Use YAML to zip up persistent data | ||
| 48 | |||
| 49 | =head1 SYNOPSIS | ||
| 50 | |||
| 51 | use Apache::Session::Serialize::DBMS::YAML; | ||
| 52 | |||
| 53 | $zipped = Apache::Session::Serialize::DBMS::YAML::serialize($ref); | ||
| 54 | $ref = Apache::Session::Serialize::DBMS::YAML::unserialize($zipped); | ||
| 55 | |||
| 56 | =head1 DESCRIPTION | ||
| 57 | |||
| 58 | This module fulfills the serialization interface of Apache::Session. | ||
| 59 | It serializes the data in the session object by use of YAML's | ||
| 60 | C<Dump()> and C<Load()> functions. The result is a binary object ready | ||
| 61 | for storage. | ||
| 62 | |||
| 63 | =head1 AUTHOR | ||
| 64 | |||
| 65 | This module was written by Alberto Reggiori <alberto@asemantics.com> | ||
| 66 | |||
| 67 | =head1 SEE ALSO | ||
| 68 | |||
| 69 | L<Apache::Session::DBMS>, L<YAML> |