MediaWiki REL1_39
GlobalIdGenerator.php
Go to the documentation of this file.
1<?php
22
23use InvalidArgumentException;
24use RuntimeException;
25use Wikimedia\Assert\Assert;
26use Wikimedia\AtEase\AtEase;
27use Wikimedia\Timestamp\ConvertibleTimestamp;
28
36 protected $shellCallback;
37
39 protected $tmpDir;
46 protected $nodeIdFile;
48 protected $nodeId32;
50 protected $nodeId48;
51
53 protected $loaded = false;
55 protected $lockFile88;
57 protected $lockFile128;
59 protected $lockFileUUID;
60
62 protected $fileHandles = [];
63
65 public const QUICK_VOLATILE = 1;
66
71 private const FILE_PREFIX = 'mw-GlobalIdGenerator';
72
74 private const CLOCK_TIME = 'time';
76 private const CLOCK_COUNTER = 'counter';
78 private const CLOCK_SEQUENCE = 'clkSeq';
80 private const CLOCK_OFFSET = 'offset';
82 private const CLOCK_OFFSET_COUNTER = 'offsetCounter';
83
88 public function __construct( $tempDirectory, $shellCallback ) {
89 if ( func_num_args() >= 3 && !is_callable( $shellCallback ) ) {
90 trigger_error(
91 __CLASS__ . ' with a BagOStuff instance was deprecated in MediaWiki 1.37.',
92 E_USER_DEPRECATED
93 );
94 $shellCallback = func_get_arg( 2 );
95 }
96 if ( !strlen( $tempDirectory ) ) {
97 throw new InvalidArgumentException( "No temp directory provided" );
98 }
99 $this->tmpDir = $tempDirectory;
100 // Check if getmyuid exists, it could be disabled for security reasons - T324513
101 $fileSuffix = function_exists( 'getmyuid' ) ? getmyuid() : '';
102 $this->uniqueFilePrefix = self::FILE_PREFIX . $fileSuffix;
103 $this->nodeIdFile = $tempDirectory . '/' . $this->uniqueFilePrefix . '-UID-nodeid';
104 // If different processes run as different users, they may have different temp dirs.
105 // This is dealt with by initializing the clock sequence number and counters randomly.
106 $this->lockFile88 = $tempDirectory . '/' . $this->uniqueFilePrefix . '-UID-88';
107 $this->lockFile128 = $tempDirectory . '/' . $this->uniqueFilePrefix . '-UID-128';
108 $this->lockFileUUID = $tempDirectory . '/' . $this->uniqueFilePrefix . '-UUID-128';
109
110 $this->shellCallback = $shellCallback;
111 }
112
128 public function newTimestampedUID88( int $base = 10 ) {
129 Assert::parameter( $base <= 36, '$base', 'must be <= 36' );
130 Assert::parameter( $base >= 2, '$base', 'must be >= 2' );
131
132 $info = $this->getTimeAndDelay( 'lockFile88', 1, 1024, 1024 );
133 $info[self::CLOCK_OFFSET_COUNTER] %= 1024;
134
135 return \Wikimedia\base_convert( $this->getTimestampedID88( $info ), 2, $base );
136 }
137
143 protected function getTimestampedID88( array $info ) {
144 $time = $info[self::CLOCK_TIME];
145 $counter = $info[self::CLOCK_OFFSET_COUNTER];
146 // Take the 46 LSBs of "milliseconds since epoch"
147 $id_bin = $this->millisecondsSinceEpochBinary( $time );
148 // Add a 10 bit counter resulting in 56 bits total
149 $id_bin .= str_pad( decbin( $counter ), 10, '0', STR_PAD_LEFT );
150 // Add the 32 bit node ID resulting in 88 bits total
151 $id_bin .= $this->getNodeId32();
152 // Convert to a 1-27 digit integer string
153 if ( strlen( $id_bin ) !== 88 ) {
154 throw new RuntimeException( "Detected overflow for millisecond timestamp." );
155 }
156
157 return $id_bin;
158 }
159
174 public function newTimestampedUID128( int $base = 10 ) {
175 Assert::parameter( $base <= 36, '$base', 'must be <= 36' );
176 Assert::parameter( $base >= 2, '$base', 'must be >= 2' );
177
178 $info = $this->getTimeAndDelay( 'lockFile128', 16384, 1048576, 1048576 );
179 $info[self::CLOCK_OFFSET_COUNTER] %= 1048576;
180
181 return \Wikimedia\base_convert( $this->getTimestampedID128( $info ), 2, $base );
182 }
183
189 protected function getTimestampedID128( array $info ) {
190 $time = $info[self::CLOCK_TIME];
191 $counter = $info[self::CLOCK_OFFSET_COUNTER];
192 $clkSeq = $info[self::CLOCK_SEQUENCE];
193 // Take the 46 LSBs of "milliseconds since epoch"
194 $id_bin = $this->millisecondsSinceEpochBinary( $time );
195 // Add a 20 bit counter resulting in 66 bits total
196 $id_bin .= str_pad( decbin( $counter ), 20, '0', STR_PAD_LEFT );
197 // Add a 14 bit clock sequence number resulting in 80 bits total
198 $id_bin .= str_pad( decbin( $clkSeq ), 14, '0', STR_PAD_LEFT );
199 // Add the 48 bit node ID resulting in 128 bits total
200 $id_bin .= $this->getNodeId48();
201 // Convert to a 1-39 digit integer string
202 if ( strlen( $id_bin ) !== 128 ) {
203 throw new RuntimeException( "Detected overflow for millisecond timestamp." );
204 }
205
206 return $id_bin;
207 }
208
215 public function newUUIDv1() {
216 // There can be up to 10000 intervals for the same millisecond timestamp.
217 // [0,4999] counter + [0,5000] offset is in [0,9999] for the offset counter.
218 // Add this onto the timestamp to allow making up to 5000 IDs per second.
219 return $this->getUUIDv1( $this->getTimeAndDelay( 'lockFileUUID', 16384, 5000, 5001 ) );
220 }
221
226 protected function getUUIDv1( array $info ) {
227 $clkSeq_bin = \Wikimedia\base_convert( $info[self::CLOCK_SEQUENCE], 10, 2, 14 );
228 $time_bin = $this->intervalsSinceGregorianBinary(
229 $info[self::CLOCK_TIME],
230 $info[self::CLOCK_OFFSET_COUNTER]
231 );
232 // Take the 32 bits of "time low"
233 $id_bin = substr( $time_bin, 28, 32 );
234 // Add 16 bits of "time mid" resulting in 48 bits total
235 $id_bin .= substr( $time_bin, 12, 16 );
236 // Add 4 bit version resulting in 52 bits total
237 $id_bin .= '0001';
238 // Add 12 bits of "time high" resulting in 64 bits total
239 $id_bin .= substr( $time_bin, 0, 12 );
240 // Add 2 bits of "variant" resulting in 66 bits total
241 $id_bin .= '10';
242 // Add 6 bits of "clock seq high" resulting in 72 bits total
243 $id_bin .= substr( $clkSeq_bin, 0, 6 );
244 // Add 8 bits of "clock seq low" resulting in 80 bits total
245 $id_bin .= substr( $clkSeq_bin, 6, 8 );
246 // Add the 48 bit node ID resulting in 128 bits total
247 $id_bin .= $this->getNodeId48();
248 // Convert to a 32 char hex string with dashes
249 if ( strlen( $id_bin ) !== 128 ) {
250 throw new RuntimeException( "Detected overflow for millisecond timestamp." );
251 }
252 $hex = \Wikimedia\base_convert( $id_bin, 2, 16, 32 );
253 return sprintf( '%s-%s-%s-%s-%s',
254 // "time_low" (32 bits)
255 substr( $hex, 0, 8 ),
256 // "time_mid" (16 bits)
257 substr( $hex, 8, 4 ),
258 // "time_hi_and_version" (16 bits)
259 substr( $hex, 12, 4 ),
260 // "clk_seq_hi_res" (8 bits) and "clk_seq_low" (8 bits)
261 substr( $hex, 16, 4 ),
262 // "node" (48 bits)
263 substr( $hex, 20, 12 )
264 );
265 }
266
273 public function newRawUUIDv1() {
274 return str_replace( '-', '', $this->newUUIDv1() );
275 }
276
283 public function newUUIDv4() {
284 $hex = bin2hex( random_bytes( 32 / 2 ) );
285
286 return sprintf( '%s-%s-%s-%s-%s',
287 // "time_low" (32 bits)
288 substr( $hex, 0, 8 ),
289 // "time_mid" (16 bits)
290 substr( $hex, 8, 4 ),
291 // "time_hi_and_version" (16 bits)
292 '4' . substr( $hex, 12, 3 ),
293 // "clk_seq_hi_res" (8 bits, variant is binary 10x) and "clk_seq_low" (8 bits)
294 dechex( 0x8 | ( hexdec( $hex[15] ) & 0x3 ) ) . $hex[16] . substr( $hex, 17, 2 ),
295 // "node" (48 bits)
296 substr( $hex, 19, 12 )
297 );
298 }
299
306 public function newRawUUIDv4() {
307 return str_replace( '-', '', $this->newUUIDv4() );
308 }
309
322 public function newSequentialPerNodeID( $bucket, $bits = 48, $flags = 0 ) {
323 return current( $this->newSequentialPerNodeIDs( $bucket, $bits, 1, $flags ) );
324 }
325
336 public function newSequentialPerNodeIDs( $bucket, $bits, $count, $flags = 0 ) {
337 return $this->getSequentialPerNodeIDs( $bucket, $bits, $count, $flags );
338 }
339
347 public function getTimestampFromUUIDv1( string $uuid, int $format = TS_MW ) {
348 $components = [];
349 if ( !preg_match(
350 '/^([0-9a-f]{8})-([0-9a-f]{4})-(1[0-9a-f]{3})-([89ab][0-9a-f]{3})-([0-9a-f]{12})$/',
351 $uuid,
352 $components
353 ) ) {
354 throw new InvalidArgumentException( "Invalid UUIDv1 {$uuid}" );
355 }
356
357 $timestamp = hexdec( substr( $components[3], 1 ) . $components[2] . $components[1] );
358 // The 60 bit timestamp value is constructed from fields of this UUID.
359 // The timestamp is measured in 100-nanosecond units since midnight, October 15, 1582 UTC.
360 $unixTime = ( $timestamp - 0x01b21dd213814000 ) / 1e7;
361
362 return ConvertibleTimestamp::convert( $format, $unixTime );
363 }
364
376 protected function getSequentialPerNodeIDs( $bucket, $bits, $count, $flags ) {
377 if ( $count <= 0 ) {
378 return [];
379 }
380 if ( $bits < 16 || $bits > 48 ) {
381 throw new RuntimeException( "Requested bit size ($bits) is out of range." );
382 }
383
384 $path = $this->tmpDir . '/' . $this->uniqueFilePrefix . '-' . rawurlencode( $bucket ) . '-48';
385 // Get the UID lock file handle
386 if ( isset( $this->fileHandles[$path] ) ) {
387 $handle = $this->fileHandles[$path];
388 } else {
389 $handle = fopen( $path, 'cb+' );
390 $this->fileHandles[$path] = $handle ?: null;
391 }
392 // Acquire the UID lock file
393 if ( $handle === false ) {
394 throw new RuntimeException( "Could not open '{$path}'." );
395 }
396 if ( !flock( $handle, LOCK_EX ) ) {
397 fclose( $handle );
398 throw new RuntimeException( "Could not acquire '{$path}'." );
399 }
400 // Fetch the counter value and increment it...
401 rewind( $handle );
402
403 // fetch as float
404 $counter = floor( (float)trim( fgets( $handle ) ) ) + $count;
405
406 // Write back the new counter value
407 ftruncate( $handle, 0 );
408 rewind( $handle );
409
410 // Use fmod() to avoid "division by zero" on 32 bit machines
411 // warp-around as needed
412 fwrite( $handle, (string)fmod( $counter, 2 ** 48 ) );
413 fflush( $handle );
414
415 // Release the UID lock file
416 flock( $handle, LOCK_UN );
417
418 $ids = [];
419 $divisor = 2 ** $bits;
420
421 // pre-increment counter value
422 $currentId = floor( $counter - $count );
423 for ( $i = 0; $i < $count; ++$i ) {
424 // Use fmod() to avoid "division by zero" on 32 bit machines
425 $ids[] = fmod( ++$currentId, $divisor );
426 }
427
428 return $ids;
429 }
430
448 protected function getTimeAndDelay( $lockFile, $clockSeqSize, $counterSize, $offsetSize ) {
449 // Get the UID lock file handle
450 if ( isset( $this->fileHandles[$this->$lockFile] ) ) {
451 $handle = $this->fileHandles[$this->$lockFile];
452 } else {
453 $handle = fopen( $this->$lockFile, 'cb+' );
454 $this->fileHandles[$this->$lockFile] = $handle ?: null;
455 }
456 // Acquire the UID lock file
457 if ( $handle === false ) {
458 throw new RuntimeException( "Could not open '{$this->$lockFile}'." );
459 }
460 if ( !flock( $handle, LOCK_EX ) ) {
461 fclose( $handle );
462 throw new RuntimeException( "Could not acquire '{$this->$lockFile}'." );
463 }
464
465 // The formatters that use this method expect a timestamp with millisecond
466 // precision and a counter upto a certain size. When more IDs than the counter
467 // size are generated during the same timestamp, an exception is thrown as we
468 // cannot increment further, because the formatted ID would not have enough
469 // bits to fit the counter.
470 //
471 // To orchestrate this between independent PHP processes on the same host,
472 // we must have a common sense of time so that we only have to maintain
473 // a single counter in a single lock file.
474 //
475 // Given that:
476 // * The system clock can be observed via time(), without milliseconds.
477 // * Some other clock can be observed via microtime(), which also offers
478 // millisecond precision.
479 // * microtime() drifts in-process further and further away from the system
480 // clock the longer a process runs for.
481 // For example, on 2018-10-03 an HHVM 3.18 JobQueue process at WMF,
482 // that ran for 9 min 55 sec, microtime drifted by 7 seconds.
483 // time() does not have this problem. See https://bugs.php.net/bug.php?id=42659.
484 //
485 // We have two choices:
486 //
487 // 1. Use microtime() with the following caveats:
488 // - The last stored time may be in the future, or our current time may be in the
489 // past, in which case we'll frequently enter the slow timeWaitUntil() method to
490 // try and "sync" the current process with the previous process.
491 // We mustn't block for long though, max 10ms?
492 // - For any drift above 10ms, we pretend that the clock went backwards, and treat
493 // it the same way as after an NTP sync, by incrementing clock sequence instead.
494 // Given the sequence rolls over automatically, and silently, and is meant to be
495 // rare, this is essentially sacrifices a reasonable guarantee of uniqueness.
496 // - For long running processes (e.g. longer than a few seconds) the drift can
497 // easily be more than 2 seconds. Because we only have a single lock file
498 // and don't want to keep too many counters and deal with clearing those,
499 // we fatal the user and refuse to make an ID. (T94522)
500 // - This offers terrible service availability.
501 // 2. Use time() instead, and expand the counter size by 1000x and use its
502 // digits as if they were the millisecond fraction of our timestamp.
503 // Known caveats or perf impact: None. We still need to read-write our
504 // lock file on each generation, so might as well make the most of it.
505 //
506 // We choose the latter.
507 $msecCounterSize = $counterSize * 1000;
508
509 rewind( $handle );
510 // Format of lock file contents:
511 // "<clk seq> <sec> <msec counter> <rand offset>"
512 $data = explode( ' ', fgets( $handle ) );
513
514 if ( count( $data ) === 4 ) {
515 // The UID lock file was already initialized
516 $clkSeq = (int)$data[0] % $clockSeqSize;
517 $prevSec = (int)$data[1];
518 // Counter for UIDs with the same timestamp,
519 $msecCounter = 0;
520 $randOffset = (int)$data[3] % $counterSize;
521
522 // If the system clock moved backwards by an NTP sync,
523 // or if the last writer process had its clock drift ahead,
524 // Try to catch up if the gap is small, so that we can keep a single
525 // monotonic logic file.
526 $sec = $this->timeWaitUntil( $prevSec );
527 if ( $sec === false ) {
528 // Gap is too big. Looks like the clock got moved back significantly.
529 // Start a new clock sequence, and re-randomize the extra offset,
530 // which is useful for UIDs that do not include the clock sequence number.
531 $clkSeq = ( $clkSeq + 1 ) % $clockSeqSize;
532 $sec = time();
533 $randOffset = mt_rand( 0, $offsetSize - 1 );
534 trigger_error( "Clock was set back; sequence number incremented." );
535 } elseif ( $sec === $prevSec ) {
536 // Double check, only keep remainder if a previous writer wrote
537 // something here that we don't accept.
538 $msecCounter = (int)$data[2] % $msecCounterSize;
539 // Bump the counter if the time has not changed yet
540 if ( ++$msecCounter >= $msecCounterSize ) {
541 // More IDs generated with the same time than counterSize can accommodate
542 flock( $handle, LOCK_UN );
543 throw new RuntimeException( "Counter overflow for timestamp value." );
544 }
545 }
546 } else {
547 // Initialize UID lock file information
548 $clkSeq = mt_rand( 0, $clockSeqSize - 1 );
549 $sec = time();
550 $msecCounter = 0;
551 $randOffset = mt_rand( 0, $offsetSize - 1 );
552 }
553
554 // Update and release the UID lock file
555 ftruncate( $handle, 0 );
556 rewind( $handle );
557 fwrite( $handle, "{$clkSeq} {$sec} {$msecCounter} {$randOffset}" );
558 fflush( $handle );
559 flock( $handle, LOCK_UN );
560
561 // Split msecCounter back into msec and counter
562 $msec = (int)( $msecCounter / 1000 );
563 $counter = $msecCounter % 1000;
564
565 return [
566 self::CLOCK_TIME => [ $sec, $msec ],
567 self::CLOCK_COUNTER => $counter,
568 self::CLOCK_SEQUENCE => $clkSeq,
569 self::CLOCK_OFFSET => $randOffset,
570 self::CLOCK_OFFSET_COUNTER => $counter + $randOffset,
571 ];
572 }
573
581 protected function timeWaitUntil( $time ) {
582 $start = microtime( true );
583 do {
584 $ct = time();
585 // https://www.php.net/manual/en/language.operators.comparison.php
586 if ( $ct >= $time ) {
587 // current time is higher than or equal to than $time
588 return $ct;
589 }
590 // up to 10ms
591 } while ( ( microtime( true ) - $start ) <= 0.010 );
592
593 return false;
594 }
595
601 protected function millisecondsSinceEpochBinary( array $time ) {
602 list( $sec, $msec ) = $time;
603 $ts = 1000 * $sec + $msec;
604 if ( $ts > 2 ** 52 ) {
605 throw new RuntimeException( __METHOD__ .
606 ': sorry, this function doesn\'t work after the year 144680' );
607 }
608
609 return substr( \Wikimedia\base_convert( (string)$ts, 10, 2, 46 ), -46 );
610 }
611
618 protected function intervalsSinceGregorianBinary( array $time, $delta = 0 ) {
619 list( $sec, $msec ) = $time;
620 $offset = '122192928000000000';
621
622 // 64 bit integers
623 if ( PHP_INT_SIZE >= 8 ) {
624 $ts = ( 1000 * $sec + $msec ) * 10000 + (int)$offset + $delta;
625 $id_bin = str_pad( decbin( $ts % ( 2 ** 60 ) ), 60, '0', STR_PAD_LEFT );
626 } elseif ( extension_loaded( 'gmp' ) ) {
627 // ms
628 $ts = gmp_add( gmp_mul( (string)$sec, '1000' ), (string)$msec );
629 // 100ns intervals
630 $ts = gmp_add( gmp_mul( $ts, '10000' ), $offset );
631 $ts = gmp_add( $ts, (string)$delta );
632 // wrap around
633 $ts = gmp_mod( $ts, gmp_pow( '2', 60 ) );
634 $id_bin = str_pad( gmp_strval( $ts, 2 ), 60, '0', STR_PAD_LEFT );
635 } elseif ( extension_loaded( 'bcmath' ) ) {
636 // ms
637 $ts = bcadd( bcmul( $sec, '1000' ), $msec );
638 // 100ns intervals
639 $ts = bcadd( bcmul( $ts, '10000' ), $offset );
640 $ts = bcadd( $ts, (string)$delta );
641 // wrap around
642 $ts = bcmod( $ts, bcpow( '2', '60' ) );
643 $id_bin = \Wikimedia\base_convert( $ts, 10, 2, 60 );
644 } else {
645 throw new RuntimeException( 'bcmath or gmp extension required for 32 bit machines.' );
646 }
647 return $id_bin;
648 }
649
653 private function load() {
654 if ( $this->loaded ) {
655 return;
656 }
657
658 $this->loaded = true;
659
660 $nodeId = '';
661 if ( is_file( $this->nodeIdFile ) ) {
662 $nodeId = file_get_contents( $this->nodeIdFile );
663 }
664 // Try to get some ID that uniquely identifies this machine (RFC 4122)...
665 if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
666 AtEase::suppressWarnings();
667 if ( PHP_OS_FAMILY === 'Windows' ) {
668 // https://technet.microsoft.com/en-us/library/bb490913.aspx
669 $csv = trim( ( $this->shellCallback )( 'getmac /NH /FO CSV' ) );
670 $line = substr( $csv, 0, strcspn( $csv, "\n" ) );
671 $info = str_getcsv( $line, ",", "\"", "\\" );
672 // @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal False positive
673 $nodeId = isset( $info[0] ) ? str_replace( '-', '', $info[0] ) : '';
674 } elseif ( is_executable( '/sbin/ifconfig' ) ) {
675 // Linux/BSD/Solaris/OS X
676 // See https://linux.die.net/man/8/ifconfig
677 $m = [];
678 preg_match( '/\s([0-9a-f]{2}(?::[0-9a-f]{2}){5})\s/',
679 ( $this->shellCallback )( '/sbin/ifconfig -a' ), $m );
680 $nodeId = isset( $m[1] ) ? str_replace( ':', '', $m[1] ) : '';
681 }
682 AtEase::restoreWarnings();
683 if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
684 $nodeId = bin2hex( random_bytes( 12 / 2 ) );
685 // set multicast bit
686 $nodeId[1] = dechex( hexdec( $nodeId[1] ) | 0x1 );
687 }
688 file_put_contents( $this->nodeIdFile, $nodeId );
689 }
690 $this->nodeId32 = \Wikimedia\base_convert( substr( sha1( $nodeId ), 0, 8 ), 16, 2, 32 );
691 $this->nodeId48 = \Wikimedia\base_convert( $nodeId, 16, 2, 48 );
692 }
693
697 private function getNodeId32() {
698 $this->load();
699
700 return $this->nodeId32;
701 }
702
706 private function getNodeId48() {
707 $this->load();
708
709 return $this->nodeId48;
710 }
711
723 private function deleteCacheFiles() {
724 foreach ( $this->fileHandles as $path => $handle ) {
725 if ( $handle !== null ) {
726 fclose( $handle );
727 }
728 if ( is_file( $path ) ) {
729 unlink( $path );
730 }
731 unset( $this->fileHandles[$path] );
732 }
733 if ( is_file( $this->nodeIdFile ) ) {
734 unlink( $this->nodeIdFile );
735 }
736 }
737
750 public function unitTestTearDown() {
751 $this->deleteCacheFiles();
752 }
753
754 public function __destruct() {
755 // @phan-suppress-next-line PhanPluginUseReturnValueInternalKnown
756 array_map( 'fclose', array_filter( $this->fileHandles ) );
757 }
758}
Class for getting statistically unique IDs without a central coordinator.
newRawUUIDv1()
Return an RFC4122 compliant v1 UUID.
newTimestampedUID88(int $base=10)
Get a statistically unique 88-bit unsigned integer ID string.
newSequentialPerNodeID( $bucket, $bits=48, $flags=0)
Return an ID that is sequential only for this node and bucket.
newTimestampedUID128(int $base=10)
Get a statistically unique 128-bit unsigned integer ID string.
newUUIDv4()
Return an RFC4122 compliant v4 UUID.
getSequentialPerNodeIDs( $bucket, $bits, $count, $flags)
Return IDs that are sequential only for this node and bucket.
newRawUUIDv4()
Return an RFC4122 compliant v4 UUID.
unitTestTearDown()
Cleanup resources when tearing down after a unit test (T46850)
string $uniqueFilePrefix
File prefix containing user ID to prevent collisions if multiple users run MediaWiki (T268420) and ge...
string $tmpDir
Temporary directory.
string $nodeId32
Node ID in binary (32 bits)
string $nodeId48
Node ID in binary (48 bits)
__construct( $tempDirectory, $shellCallback)
timeWaitUntil( $time)
Wait till the current timestamp reaches $time and return the current timestamp.
bool $loaded
Whether initialization completed.
newUUIDv1()
Return an RFC4122 compliant v1 UUID.
string $lockFile128
Local file path.
array $fileHandles
Cached file handles.
getTimestampFromUUIDv1(string $uuid, int $format=TS_MW)
Get timestamp in a specified format from UUIDv1.
callable $shellCallback
Callback for running shell commands.
getTimeAndDelay( $lockFile, $clockSeqSize, $counterSize, $offsetSize)
Get a (time,counter,clock sequence) where (time,counter) is higher than any previous (time,...
string $lockFileUUID
Local file path.
newSequentialPerNodeIDs( $bucket, $bits, $count, $flags=0)
Return IDs that are sequential only for this node and bucket.
intervalsSinceGregorianBinary(array $time, $delta=0)
$line
Definition mcc.php:119
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...