Class for getting statistically unique IDs.
More...
|
| __construct () |
|
| deleteCacheFiles () |
| Delete all cache files that have been created.
|
|
| getSequentialPerNodeIDs ( $bucket, $bits, $count, $flags) |
| Return IDs that are sequential only for this node and bucket.
|
|
| 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.
|
|
| 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.
|
|
Class for getting statistically unique IDs.
- Since
- 1.21
Definition at line 30 of file UIDGenerator.php.
◆ __construct()
UIDGenerator::__construct |
( |
| ) |
|
|
protected |
◆ __destruct()
UIDGenerator::__destruct |
( |
| ) |
|
◆ deleteCacheFiles()
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 593 of file UIDGenerator.php.
◆ getSequentialPerNodeIDs()
UIDGenerator::getSequentialPerNodeIDs |
( |
| $bucket, |
|
|
| $bits, |
|
|
| $count, |
|
|
| $flags ) |
|
protected |
◆ getTimeAndDelay()
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 431 of file UIDGenerator.php.
References $time, millitime(), and timeWaitUntil().
◆ getTimestampedID128()
UIDGenerator::getTimestampedID128 |
( |
array | $info | ) |
|
|
protected |
◆ getTimestampedID88()
UIDGenerator::getTimestampedID88 |
( |
array | $info | ) |
|
|
protected |
◆ getUUIDv1()
UIDGenerator::getUUIDv1 |
( |
array | $info | ) |
|
|
protected |
◆ intervalsSinceGregorianBinary()
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 549 of file UIDGenerator.php.
References $time, and list.
Referenced by getUUIDv1().
◆ millisecondsSinceEpochBinary()
UIDGenerator::millisecondsSinceEpochBinary |
( |
array | $time | ) |
|
|
protected |
◆ millitime()
static UIDGenerator::millitime |
( |
| ) |
|
|
staticprotected |
◆ newRawUUIDv1()
static UIDGenerator::newRawUUIDv1 |
( |
| ) |
|
|
static |
◆ newRawUUIDv4()
static UIDGenerator::newRawUUIDv4 |
( |
| $flags = 0 | ) |
|
|
static |
◆ newSequentialPerNodeID()
static UIDGenerator::newSequentialPerNodeID |
( |
| $bucket, |
|
|
| $bits = 48, |
|
|
| $flags = 0 ) |
|
static |
◆ newSequentialPerNodeIDs()
static UIDGenerator::newSequentialPerNodeIDs |
( |
| $bucket, |
|
|
| $bits, |
|
|
| $count, |
|
|
| $flags = 0 ) |
|
static |
◆ 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 | $base | Specifies a base other than 10 |
- Returns
- string Number
- Exceptions
-
Definition at line 166 of file UIDGenerator.php.
References $base, and singleton().
Referenced by ExternalStoreMwstore\store().
◆ 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 | $base | Specifies a base other than 10 |
- Returns
- string Number
- Exceptions
-
Definition at line 113 of file UIDGenerator.php.
References $base, and singleton().
◆ newUUIDv1()
static UIDGenerator::newUUIDv1 |
( |
| ) |
|
|
static |
◆ newUUIDv4()
static UIDGenerator::newUUIDv4 |
( |
| $flags = 0 | ) |
|
|
static |
◆ singleton()
static UIDGenerator::singleton |
( |
| ) |
|
|
staticprotected |
◆ timeWaitUntil()
UIDGenerator::timeWaitUntil |
( |
array | $time | ) |
|
|
protected |
◆ unitTestTearDown()
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 620 of file UIDGenerator.php.
References singleton().
Referenced by UIDGeneratorTest\tearDown().
◆ $fileHandles
array UIDGenerator::$fileHandles = [] |
|
protected |
◆ $instance
◆ $lockFile128
UIDGenerator::$lockFile128 |
|
protected |
◆ $lockFile88
UIDGenerator::$lockFile88 |
|
protected |
◆ $lockFileUUID
UIDGenerator::$lockFileUUID |
|
protected |
◆ $nodeId32
◆ $nodeId48
◆ $nodeIdFile
UIDGenerator::$nodeIdFile |
|
protected |
◆ QUICK_RAND
const UIDGenerator::QUICK_RAND = 1 |
◆ QUICK_VOLATILE
const UIDGenerator::QUICK_VOLATILE = 2 |
The documentation for this class was generated from the following file: