Documentation

CombGenerator
in package
implements RandomGeneratorInterface

CombGenerator generates COMBs (combined UUID/timestamp)

The CombGenerator, when used with the StringCodec (and, by proxy, the TimestampLastCombCodec) or the TimestampFirstCombCodec, combines the current timestamp with a UUID (hence the name "COMB"). The timestamp either appears as the first or last 48 bits of the COMB, depending on the codec used.

By default, COMBs will have the timestamp set as the last 48 bits of the identifier.

$factory = new UuidFactory();

$factory->setRandomGenerator(new CombGenerator(
    $factory->getRandomGenerator(),
    $factory->getNumberConverter()
));

$comb = $factory->uuid4();

To generate a COMB with the timestamp as the first 48 bits, set the TimestampFirstCombCodec as the codec.

$factory->setCodec(new TimestampFirstCombCodec($factory->getUuidBuilder()));
Tags
link

The Cost of GUIDs as Primary Keys

Interfaces, Classes, Traits and Enums

RandomGeneratorInterface
A random generator generates strings of random binary data

Table of Contents

TIMESTAMP_BYTES  = 6
$converter  : NumberConverterInterface
$randomGenerator  : RandomGeneratorInterface
__construct()  : mixed
generate()  : string
Generates a string of randomized binary data
timestamp()  : string
Returns current timestamp a string integer, precise to 0.00001 seconds

Constants

Properties

Methods

generate()

Generates a string of randomized binary data

public generate(int $length) : string
Parameters
$length : int

The number of bytes of random binary data to generate

Tags
throws
InvalidArgumentException

if $length is not a positive integer greater than or equal to CombGenerator::TIMESTAMP_BYTES

inheritDoc
Return values
string

A binary string

timestamp()

Returns current timestamp a string integer, precise to 0.00001 seconds

private timestamp() : string
Return values
string

Search results