View on
Tatsuhiko Miyagawa > Data-YUID-0.03 > Data::YUID



Annotate this POD


New  1
Open  1
View/Report Bugs
Module Version: 0.03   Source   Latest Release: Data-YUID-0.06


Data::YUID - Distributed ID generator ("Yet another Unique ID")


    ## Generating a unique ID within a particular process...
    use Data::YUID::Generator;
    my $generator = Data::YUID::Generator->new;
    my $id = $generator->get_id;

    ## Generating a unique ID from a set of distributed servers...
    use Data::YUID::Client;
    my $client = Data::YUID::Client->new(
            servers => [
    my $id = $client->get_id;


Data::YUID ("Yet another Unique ID") is an ID allocation engine that can be used both in client/server mode--with a set of distributed servers--and within a single process.

It generates IDs with temporal and spatial uniqueness. These IDs are less universally unique than Type-1 UUIDs, because they have only 64 bits of usable ID space split up between the various parts. Currently, ID generation uses this split:

16 bits of host ID (akin to a locally provisioned MAC address) 36 bits of time in seconds since the epoch (currently Jan 1 2000 00:00 GMT) 12 bits of serial incrementor

Given the following restrictions, a YUID generator will generate guaranteed globally (within your control) unique IDs:

1. no two hosts with the same host ID are running simultaneously
2. for a given ID namespace, no more than (T - S) * (2^12) IDs have been generated, where T = current time and S = start time of generator

The size of the incrementor is dependent on the rate of request. For IDs with a short lifetime but high request rate, you could use fewer time bits and more serial bits.


See Data::YUID::Client and Data::YUID::Generator for usage details.


Data::YUID is free software; you may redistribute it and/or modify it under the same terms as Perl itself.


Except where otherwise noted, Data::YUID is Copyright 2005 Six Apart, All rights reserved.

syntax highlighting: