Class for getting statistically unique IDs.
More...
|
| __construct () |
|
| deleteCacheFiles () |
| Delete all cache files that have been created. More...
|
|
| getSequentialPerNodeIDs ($bucket, $bits, $count, $flags) |
| Return IDs that are sequential only for this node and bucket. More...
|
|
| getTimeAndDelay ($lockFile, $clockSeqSize, $counterSize, $offsetSize) |
| Get a (time,counter,clock sequence) where (time,counter) is higher than any previous (time,counter) value for the given clock sequence. More...
|
|
| getTimestampedID128 (array $info) |
|
| getTimestampedID88 (array $info) |
|
| getUUIDv1 (array $info) |
|
| intervalsSinceGregorianBinary (array $time, $delta=0) |
|
| millisecondsSinceEpochBinary (array $time) |
|
| timeWaitUntil (array $time) |
| Wait till the current timestamp reaches $time and return the current timestamp. More...
|
|
Class for getting statistically unique IDs.
- Since
- 1.21
Definition at line 31 of file UIDGenerator.php.
UIDGenerator::__construct |
( |
| ) |
|
|
protected |
UIDGenerator::__destruct |
( |
| ) |
|
UIDGenerator::deleteCacheFiles |
( |
| ) |
|
|
protected |
Delete all cache files that have been created.
This is a cleanup method primarily meant to be used from unit tests to avoid poluting the local filesystem. If used outside of a unit test environment it should be used with caution as it may destroy state saved in the files.
- See also
- unitTestTearDown
- Since
- 1.23
Definition at line 594 of file UIDGenerator.php.
References $path, and as.
UIDGenerator::getSequentialPerNodeIDs |
( |
|
$bucket, |
|
|
|
$bits, |
|
|
|
$count, |
|
|
|
$flags |
|
) |
| |
|
protected |
UIDGenerator::getTimeAndDelay |
( |
|
$lockFile, |
|
|
|
$clockSeqSize, |
|
|
|
$counterSize, |
|
|
|
$offsetSize |
|
) |
| |
|
protected |
Get a (time,counter,clock sequence) where (time,counter) is higher than any previous (time,counter) value for the given clock sequence.
This is useful for making UIDs sequential on a per-node bases.
- Parameters
-
string | $lockFile | Name of a local lock file |
int | $clockSeqSize | The number of possible clock sequence values |
int | $counterSize | The number of possible counter values |
int | $offsetSize | The number of possible offset values |
- Returns
- array (result of UIDGenerator::millitime(), counter, clock sequence)
- Exceptions
-
Definition at line 432 of file UIDGenerator.php.
References $time, and timeWaitUntil().
UIDGenerator::getTimestampedID128 |
( |
array |
$info | ) |
|
|
protected |
UIDGenerator::getTimestampedID88 |
( |
array |
$info | ) |
|
|
protected |
UIDGenerator::getUUIDv1 |
( |
array |
$info | ) |
|
|
protected |
UIDGenerator::intervalsSinceGregorianBinary |
( |
array |
$time, |
|
|
|
$delta = 0 |
|
) |
| |
|
protected |
- Parameters
-
- Returns
- string 60 bits of "100ns intervals since 15 October 1582" (rolls over in 3400)
- Exceptions
-
Definition at line 550 of file UIDGenerator.php.
References $time, and list.
Referenced by getUUIDv1().
UIDGenerator::millisecondsSinceEpochBinary |
( |
array |
$time | ) |
|
|
protected |
static UIDGenerator::millitime |
( |
| ) |
|
|
staticprotected |
- Returns
- array (current time in seconds, milliseconds since then)
Definition at line 577 of file UIDGenerator.php.
References list.
static UIDGenerator::newRawUUIDv1 |
( |
| ) |
|
|
static |
static UIDGenerator::newRawUUIDv4 |
( |
|
$flags = 0 | ) |
|
|
static |
static UIDGenerator::newSequentialPerNodeID |
( |
|
$bucket, |
|
|
|
$bits = 48 , |
|
|
|
$flags = 0 |
|
) |
| |
|
static |
static UIDGenerator::newSequentialPerNodeIDs |
( |
|
$bucket, |
|
|
|
$bits, |
|
|
|
$count, |
|
|
|
$flags = 0 |
|
) |
| |
|
static |
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 | $base | Specifies a base other than 10 |
- Returns
- string Number
- Exceptions
-
Definition at line 167 of file UIDGenerator.php.
References $base.
Referenced by ExternalStoreMwstore\store().
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 | $base | Specifies a base other than 10 |
- Returns
- string Number
- Exceptions
-
Definition at line 114 of file UIDGenerator.php.
References $base.
static UIDGenerator::newUUIDv1 |
( |
| ) |
|
|
static |
static UIDGenerator::newUUIDv4 |
( |
|
$flags = 0 | ) |
|
|
static |
static UIDGenerator::singleton |
( |
| ) |
|
|
staticprotected |
UIDGenerator::timeWaitUntil |
( |
array |
$time | ) |
|
|
protected |
static UIDGenerator::unitTestTearDown |
( |
| ) |
|
|
static |
Cleanup resources when tearing down after a unit test.
This is a cleanup method primarily meant to be used from unit tests to avoid poluting the local filesystem. If used outside of a unit test environment it should be used with caution as it may destroy state saved in the files.
- See also
- deleteCacheFiles
- Since
- 1.23
Definition at line 621 of file UIDGenerator.php.
Referenced by UIDGeneratorTest\tearDown().
array UIDGenerator::$fileHandles = [] |
|
protected |
UIDGenerator::$lockFile128 |
|
protected |
UIDGenerator::$lockFile88 |
|
protected |
UIDGenerator::$lockFileUUID |
|
protected |
UIDGenerator::$nodeIdFile |
|
protected |
const UIDGenerator::QUICK_RAND = 1 |
const UIDGenerator::QUICK_VOLATILE = 2 |
The documentation for this class was generated from the following file: