<<

NAME

MT::Serialize - Data serialization library

SYNOPSIS

    my $serializer = MT::Serialize->new(MT->config->Serializer);

    my $data = { 'this' => 'is', 'my' => 'data' };
    my $frozen = $serializer->serialize( \$data );

    my $thawed = $serializer->unserialize( $frozen );

DESCRIPTION

This package provides an abstraction layer to the serialization methods that are available to Movable Type. The user can select the type of serialization they want to use by specifying it in the mt.cfg file with the 'Serializer' configuration key. 'MT' and 'Storable' are the currently available serialization methods.

USAGE

MT::Serialize::new( $type )

Constructor that returns an object with methods that are appropriate for the $type of serialization requested.

MT::Serialize->serialize( $data )

Converts the data given into a bytestream, suitable for storage in a BerkeleyDB table, a BLOB field in a database or a flat file.

Note that the $data parameter must be a reference to whatever data you want to serialize. For instance, if you are serializing a hashref, you should pass through a reference to the hashref.

MT::Serialize->unserialize( $data )

Converts a serialized bytestream given back into the original Perl data structure. It returns a reference to whatever data structure was reconstructed.

no_utf8

This function removes UTF-8 from scalars.

COMPATIBILITY NOTES

Version 2 of the native MT serializer changes the structure of the stream quite a bit, but remains backward compatible. If version 1 frozen data is fed into the MT thaw method, it will handle it using the legacy code. Then upon reserializing the data, it will be upgraded to the new format. The new encoding includes a version number which should allow us more flexibility in upgrading the encoding format in the future, without worrying about breaking or upgrading existing serialized data.

The updated protocol allows you to store most any Perl data structure, although it does not currently support references to objects, code references or globs.

<<