SPOPS::Key::UUID - Creates a Universally Unique ID (UUID) as a key


SPOPS documentation Contained in the SPOPS distribution.

Index


Code Index:

NAME

Top

SPOPS::Key::UUID - Creates a Universally Unique ID (UUID) as a key

SYNOPSIS

Top

 # In your SPOPS configuration

 $spops  = {
   'myspops' => {
       'isa'      => [ qw/ SPOPS::Key::UUID  SPOPS::DBI / ],
       ...
   },
 };

DESCRIPTION

Top

Very, very simple. We just use the Data::UUID module to create a unique key. The key is created before the object is inserted.

The docs for Data::UUID say that it can handle millions of new keys per second, which should be enough for anything Perl is running.

BUGS

Top

Unclear whether Data::UUID works on Win32.

TO DO

Top

Nothing known.

COPYRIGHT

Top

AUTHORS

Top

Chris Winters <chris@cwinters.com>


SPOPS documentation Contained in the SPOPS distribution.

package SPOPS::Key::UUID;

# $Id: UUID.pm,v 3.4 2004/06/02 00:48:23 lachoy Exp $

use strict;
use Log::Log4perl qw( get_logger );
use SPOPS;

my $log = get_logger();

$SPOPS::Key::UUID::VERSION  = sprintf("%d.%02d", q$Revision: 3.4 $ =~ /(\d+)\.(\d+)/);

BEGIN { eval { require Data::UUID } }

my $GENERATOR = Data::UUID->new();

sub pre_fetch_id  {
    my ( $class, $p ) = @_;
    return ( $GENERATOR->create_str(), 1, );
}

sub post_fetch_id { return undef }

1;

__END__