MediaWiki REL1_35
UIDGenerator Class Reference

Class for getting statistically unique IDs. More...

Static Public Member Functions

static getTimestampFromUUIDv1 (string $uuid, int $format=TS_MW)
 Get timestamp in a specified format from UUIDv1.
 
static newRawUUIDv1 ()
 Return an RFC4122 compliant v1 UUID.
 
static newRawUUIDv4 ( $flags=0)
 Return an RFC4122 compliant v4 UUID.
 
static newSequentialPerNodeID ( $bucket, $bits=48, $flags=0)
 Return an ID that is sequential only for this node and bucket.
 
static newSequentialPerNodeIDs ( $bucket, $bits, $count, $flags=0)
 Return IDs that are sequential only for this node and bucket.
 
static newTimestampedUID128 ( $base=10)
 Get a statistically unique 128-bit unsigned integer ID string.
 
static newTimestampedUID88 ( $base=10)
 Get a statistically unique 88-bit unsigned integer ID string.
 
static newUUIDv1 ()
 Return an RFC4122 compliant v1 UUID.
 
static newUUIDv4 ( $flags=0)
 Return an RFC4122 compliant v4 UUID.
 

Detailed Description

Class for getting statistically unique IDs.

Since
1.21
Deprecated:
Since 1.35; use GlobalIdGenerator instead

Definition at line 31 of file UIDGenerator.php.

Member Function Documentation

◆ getTimestampFromUUIDv1()

static UIDGenerator::getTimestampFromUUIDv1 ( string  $uuid,
int  $format = TS_MW 
)
static

Get timestamp in a specified format from UUIDv1.

Parameters
string$uuidthe UUID to get the timestamp from
int$formatthe format to convert the timestamp to. Default: TS_MW
Returns
string|false timestamp in requested format or false

Definition at line 111 of file UIDGenerator.php.

◆ newRawUUIDv1()

static UIDGenerator::newRawUUIDv1 ( )
static

Return an RFC4122 compliant v1 UUID.

Returns
string 32 hex characters with no hyphens
Exceptions
RuntimeException
Since
1.27

Definition at line 98 of file UIDGenerator.php.

◆ newRawUUIDv4()

static UIDGenerator::newRawUUIDv4 (   $flags = 0)
static

Return an RFC4122 compliant v4 UUID.

Parameters
int$flagsBitfield (unused)
Returns
string 32 hex characters with no hyphens
Exceptions
RuntimeException

Definition at line 137 of file UIDGenerator.php.

◆ newSequentialPerNodeID()

static UIDGenerator::newSequentialPerNodeID (   $bucket,
  $bits = 48,
  $flags = 0 
)
static

Return an ID that is sequential only for this node and bucket.

These IDs are suitable for per-host sequence numbers, e.g. for some packet protocols. If UIDGenerator::QUICK_VOLATILE is used the counter might reset on server restart.

Parameters
string$bucketArbitrary bucket name (should be ASCII)
int$bitsBit size (<=48) of resulting numbers before wrap-around
int$flags(supports UIDGenerator::QUICK_VOLATILE)
Returns
float Integer value as float
Since
1.23

Definition at line 155 of file UIDGenerator.php.

◆ newSequentialPerNodeIDs()

static UIDGenerator::newSequentialPerNodeIDs (   $bucket,
  $bits,
  $count,
  $flags = 0 
)
static

Return IDs that are sequential only for this node and bucket.

See also
UIDGenerator::newSequentialPerNodeID()
Parameters
string$bucketArbitrary bucket name (should be ASCII)
int$bitsBit size (16 to 48) of resulting numbers before wrap-around
int$countNumber of IDs to return
int$flags(supports UIDGenerator::QUICK_VOLATILE)
Returns
array Ordered list of float integer values
Since
1.23

Definition at line 172 of file UIDGenerator.php.

◆ newTimestampedUID128()

static UIDGenerator::newTimestampedUID128 (   $base = 10)
static

Get a statistically unique 128-bit unsigned integer ID string.

The bits of the UID are prefixed with the time (down to the millisecond).

These IDs are suitable as globally unique IDs, without any enforced uniqueness. New rows almost always have higher UIDs, which makes B-TREE updates on INSERT fast. They can also be stored as "DECIMAL(39) UNSIGNED" or BINARY(16) in MySQL.

UID generation is serialized on each server (as the node ID is for the whole machine).

Parameters
int$baseSpecifies a base other than 10
Returns
string Number
Exceptions
RuntimeException

Definition at line 72 of file UIDGenerator.php.

References $base.

◆ newTimestampedUID88()

static UIDGenerator::newTimestampedUID88 (   $base = 10)
static

Get a statistically unique 88-bit unsigned integer ID string.

The bits of the UID are prefixed with the time (down to the millisecond).

These IDs are suitable as values for the shard key of distributed data. If a column uses these as values, it should be declared UNIQUE to handle collisions. New rows almost always have higher UIDs, which makes B-TREE updates on INSERT fast. They can also be stored "DECIMAL(27) UNSIGNED" or BINARY(11) in MySQL.

UID generation is serialized on each server (as the node ID is for the whole machine).

Parameters
int$baseSpecifies a base other than 10
Returns
string Number
Exceptions
RuntimeException

Definition at line 52 of file UIDGenerator.php.

References $base.

◆ newUUIDv1()

static UIDGenerator::newUUIDv1 ( )
static

Return an RFC4122 compliant v1 UUID.

Returns
string
Exceptions
RuntimeException
Since
1.27

Definition at line 85 of file UIDGenerator.php.

◆ newUUIDv4()

static UIDGenerator::newUUIDv4 (   $flags = 0)
static

Return an RFC4122 compliant v4 UUID.

Parameters
int$flagsBitfield (unused)
Returns
string
Exceptions
RuntimeException

Definition at line 124 of file UIDGenerator.php.


The documentation for this class was generated from the following file: