NAME
Data::SUID - Generates thread-safe sequential unique ids
SYNOPSIS
use Data::SUID 'suid'; # Or use ':all' tag
use Data::Dumper;
$Data::Dumper::Indent = 0;
$Data::Dumper::Terse = 1;
my $suid = suid(); # Old school, or ...
my $suid = Data::SUID->new(); # Do it OOP style
print $suid->hex # 55de233819d51b1a8a67e0ac
print $suid->dec # 26574773684474770905501261996
print $suid->uuencode # ,5=XC.!G5&QJ*9^"L
print $suid->binary # 12 bytes of unreadable gibberish
print $suid # 55de233819d51b1a8a67e0ac
# Use the hex, dec, uuencode and binary methods as fire-and-forget
# constructors, if you prefer:
my $suid_hex = suid->hex; # If you just want the goodies
DESCRIPTION
Use this package to generate thread-safe 12-byte sequential unique ids modeled upon the MongoDB BSON ObjectId. Unlike traditional GUIDs, these some somewhat more index-friendly and reasonably suited for use as primary keys within database tables. They are guaranteed to have a high level of uniqueness, given that they contain a timestamp, a host identifier and an incremented sequence number.
METHODS
- new
-
Generates a new SUID object.
my $suid = Data::SUID->new();
- hex
-
Returns the SUID value as a 24-character hexadecimal string.
The SUID object's stringification operation has been overloaded to give this value, too.
- dec
-
Returns the SUID value as a big integer.
- uuencode
-
Returns the SUID value as a UUENCODED string.
- binary
-
Returns the SUID value as 12 bytes of binary data.
EXPORTED FUNCTIONS
- suid
-
Generates a new SUID object.
my $suid = suid();
REPOSITORY
https://github.com/cpanic/Data-SUID
BUG REPORTS
Please report any bugs to http://rt.cpan.org/
AUTHOR
Iain Campbell <cpanic@cpan.org>
COPYRIGHT AND LICENCE
Copyright (C) 2012-2015 by Iain Campbell
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.