MediaWiki REL1_35
GlobalIdGenerator.php
Go to the documentation of this file.
1<?php
22
23use BagOStuff;
25use InvalidArgumentException;
26use RuntimeException;
27use Wikimedia\Assert\Assert;
28use Wikimedia\AtEase\AtEase;
29use Wikimedia\Timestamp\ConvertibleTimestamp;
30
38 protected $srvCache;
40 protected $shellCallback;
41
43 protected $tmpDir;
45 protected $nodeIdFile;
47 protected $nodeId32;
49 protected $nodeId48;
50
52 protected $loaded = false;
54 protected $lockFile88;
56 protected $lockFile128;
58 protected $lockFileUUID;
59
61 protected $fileHandles = []; // cached file handles
62
63 public const QUICK_VOLATILE = 1; // use an APC like in-memory counter if available
64
69 private const FILE_PREFIX = 'mw-GlobalIdGenerator';
70
76 public function __construct( $tempDirectory, BagOStuff $srvCache, callable $shellCallback ) {
77 if ( !strlen( $tempDirectory ) ) {
78 throw new InvalidArgumentException( "No temp directory provided" );
79 }
80 $this->tmpDir = $tempDirectory;
81 $this->nodeIdFile = $tempDirectory . '/' . self::FILE_PREFIX . '-UID-nodeid';
82 // If different processes run as different users, they may have different temp dirs.
83 // This is dealt with by initializing the clock sequence number and counters randomly.
84 $this->lockFile88 = $tempDirectory . '/' . self::FILE_PREFIX . '-UID-88';
85 $this->lockFile128 = $tempDirectory . '/' . self::FILE_PREFIX . '-UID-128';
86 $this->lockFileUUID = $tempDirectory . '/' . self::FILE_PREFIX . '-UUID-128';
87
88 $this->srvCache = $srvCache;
89 $this->shellCallback = $shellCallback;
90 }
91
107 public function newTimestampedUID88( $base = 10 ) {
108 Assert::parameterType( 'integer', $base, '$base' );
109 Assert::parameter( $base <= 36, '$base', 'must be <= 36' );
110 Assert::parameter( $base >= 2, '$base', 'must be >= 2' );
111
112 $info = $this->getTimeAndDelay( 'lockFile88', 1, 1024, 1024 );
113 $info['offsetCounter'] %= 1024;
114
115 return \Wikimedia\base_convert( $this->getTimestampedID88( $info ), 2, $base );
116 }
117
124 protected function getTimestampedID88( array $info ) {
125 if ( isset( $info['time'] ) ) {
126 $time = $info['time'];
127 $counter = $info['offsetCounter'];
128 } else {
129 list( $time, $counter ) = $info;
130 }
131 // Take the 46 LSBs of "milliseconds since epoch"
132 $id_bin = $this->millisecondsSinceEpochBinary( $time );
133 // Add a 10 bit counter resulting in 56 bits total
134 $id_bin .= str_pad( decbin( $counter ), 10, '0', STR_PAD_LEFT );
135 // Add the 32 bit node ID resulting in 88 bits total
136 $id_bin .= $this->getNodeId32();
137 // Convert to a 1-27 digit integer string
138 if ( strlen( $id_bin ) !== 88 ) {
139 throw new RuntimeException( "Detected overflow for millisecond timestamp." );
140 }
141
142 return $id_bin;
143 }
144
159 public function newTimestampedUID128( $base = 10 ) {
160 Assert::parameterType( 'integer', $base, '$base' );
161 Assert::parameter( $base <= 36, '$base', 'must be <= 36' );
162 Assert::parameter( $base >= 2, '$base', 'must be >= 2' );
163
164 $info = $this->getTimeAndDelay( 'lockFile128', 16384, 1048576, 1048576 );
165 $info['offsetCounter'] %= 1048576;
166
167 return \Wikimedia\base_convert( $this->getTimestampedID128( $info ), 2, $base );
168 }
169
176 protected function getTimestampedID128( array $info ) {
177 if ( isset( $info['time'] ) ) {
178 $time = $info['time'];
179 $counter = $info['offsetCounter'];
180 $clkSeq = $info['clkSeq'];
181 } else {
182 list( $time, $counter, $clkSeq ) = $info;
183 }
184 // Take the 46 LSBs of "milliseconds since epoch"
185 $id_bin = $this->millisecondsSinceEpochBinary( $time );
186 // Add a 20 bit counter resulting in 66 bits total
187 $id_bin .= str_pad( decbin( $counter ), 20, '0', STR_PAD_LEFT );
188 // Add a 14 bit clock sequence number resulting in 80 bits total
189 $id_bin .= str_pad( decbin( $clkSeq ), 14, '0', STR_PAD_LEFT );
190 // Add the 48 bit node ID resulting in 128 bits total
191 $id_bin .= $this->getNodeId48();
192 // Convert to a 1-39 digit integer string
193 if ( strlen( $id_bin ) !== 128 ) {
194 throw new RuntimeException( "Detected overflow for millisecond timestamp." );
195 }
196
197 return $id_bin;
198 }
199
206 public function newUUIDv1() {
207 // There can be up to 10000 intervals for the same millisecond timestamp.
208 // [0,4999] counter + [0,5000] offset is in [0,9999] for the offset counter.
209 // Add this onto the timestamp to allow making up to 5000 IDs per second.
210 return $this->getUUIDv1( $this->getTimeAndDelay( 'lockFileUUID', 16384, 5000, 5001 ) );
211 }
212
217 protected function getUUIDv1( array $info ) {
218 $clkSeq_bin = \Wikimedia\base_convert( $info['clkSeq'], 10, 2, 14 );
219 $time_bin = $this->intervalsSinceGregorianBinary( $info['time'], $info['offsetCounter'] );
220 // Take the 32 bits of "time low"
221 $id_bin = substr( $time_bin, 28, 32 );
222 // Add 16 bits of "time mid" resulting in 48 bits total
223 $id_bin .= substr( $time_bin, 12, 16 );
224 // Add 4 bit version resulting in 52 bits total
225 $id_bin .= '0001';
226 // Add 12 bits of "time high" resulting in 64 bits total
227 $id_bin .= substr( $time_bin, 0, 12 );
228 // Add 2 bits of "variant" resulting in 66 bits total
229 $id_bin .= '10';
230 // Add 6 bits of "clock seq high" resulting in 72 bits total
231 $id_bin .= substr( $clkSeq_bin, 0, 6 );
232 // Add 8 bits of "clock seq low" resulting in 80 bits total
233 $id_bin .= substr( $clkSeq_bin, 6, 8 );
234 // Add the 48 bit node ID resulting in 128 bits total
235 $id_bin .= $this->getNodeId48();
236 // Convert to a 32 char hex string with dashes
237 if ( strlen( $id_bin ) !== 128 ) {
238 throw new RuntimeException( "Detected overflow for millisecond timestamp." );
239 }
240 $hex = \Wikimedia\base_convert( $id_bin, 2, 16, 32 );
241 return sprintf( '%s-%s-%s-%s-%s',
242 // "time_low" (32 bits)
243 substr( $hex, 0, 8 ),
244 // "time_mid" (16 bits)
245 substr( $hex, 8, 4 ),
246 // "time_hi_and_version" (16 bits)
247 substr( $hex, 12, 4 ),
248 // "clk_seq_hi_res" (8 bits) and "clk_seq_low" (8 bits)
249 substr( $hex, 16, 4 ),
250 // "node" (48 bits)
251 substr( $hex, 20, 12 )
252 );
253 }
254
261 public function newRawUUIDv1() {
262 return str_replace( '-', '', $this->newUUIDv1() );
263 }
264
271 public function newUUIDv4() {
272 $hex = bin2hex( random_bytes( 32 / 2 ) );
273
274 return sprintf( '%s-%s-%s-%s-%s',
275 // "time_low" (32 bits)
276 substr( $hex, 0, 8 ),
277 // "time_mid" (16 bits)
278 substr( $hex, 8, 4 ),
279 // "time_hi_and_version" (16 bits)
280 '4' . substr( $hex, 12, 3 ),
281 // "clk_seq_hi_res" (8 bits, variant is binary 10x) and "clk_seq_low" (8 bits)
282 dechex( 0x8 | ( hexdec( $hex[15] ) & 0x3 ) ) . $hex[16] . substr( $hex, 17, 2 ),
283 // "node" (48 bits)
284 substr( $hex, 19, 12 )
285 );
286 }
287
294 public function newRawUUIDv4() {
295 return str_replace( '-', '', $this->newUUIDv4() );
296 }
297
310 public function newSequentialPerNodeID( $bucket, $bits = 48, $flags = 0 ) {
311 return current( $this->newSequentialPerNodeIDs( $bucket, $bits, 1, $flags ) );
312 }
313
324 public function newSequentialPerNodeIDs( $bucket, $bits, $count, $flags = 0 ) {
325 return $this->getSequentialPerNodeIDs( $bucket, $bits, $count, $flags );
326 }
327
335 public function getTimestampFromUUIDv1( string $uuid, int $format = TS_MW ) {
336 $components = [];
337 if ( !preg_match(
338 '/^([0-9a-f]{8})-([0-9a-f]{4})-(1[0-9a-f]{3})-([89ab][0-9a-f]{3})-([0-9a-f]{12})$/',
339 $uuid,
340 $components
341 ) ) {
342 throw new InvalidArgumentException( "Invalid UUIDv1 {$uuid}" );
343 }
344
345 $timestamp = hexdec( substr( $components[3], 1 ) . $components[2] . $components[1] );
346 // The 60 bit timestamp value is constructed from fields of this UUID.
347 // The timestamp is measured in 100-nanosecond units since midnight, October 15, 1582 UTC.
348 $unixTime = ( $timestamp - 0x01b21dd213814000 ) / 1e7;
349
350 return ConvertibleTimestamp::convert( $format, $unixTime );
351 }
352
364 protected function getSequentialPerNodeIDs( $bucket, $bits, $count, $flags ) {
365 if ( $count <= 0 ) {
366 return []; // nothing to do
367 }
368 if ( $bits < 16 || $bits > 48 ) {
369 throw new RuntimeException( "Requested bit size ($bits) is out of range." );
370 }
371
372 $counter = null; // post-increment persistent counter value
373
374 // Use APC/etc if requested, available, and not in CLI mode;
375 // Counter values would not survive across script instances in CLI mode.
376 if (
377 ( $flags & self::QUICK_VOLATILE ) &&
378 !( $this->srvCache instanceof EmptyBagOStuff )
379 ) {
381 $counter = $cache->incrWithInit( $bucket, $cache::TTL_INDEFINITE, $count, $count );
382 if ( $counter === false ) {
383 throw new RuntimeException( 'Unable to set value to ' . get_class( $cache ) );
384 }
385 }
386
387 // Note: use of fmod() avoids "division by zero" on 32 bit machines
388 if ( $counter === null ) {
389 $path = $this->tmpDir . '/' . self::FILE_PREFIX . '-' . rawurlencode( $bucket ) . '-48';
390 // Get the UID lock file handle
391 if ( isset( $this->fileHandles[$path] ) ) {
392 $handle = $this->fileHandles[$path];
393 } else {
394 $handle = fopen( $path, 'cb+' );
395 $this->fileHandles[$path] = $handle ?: null; // cache
396 }
397 // Acquire the UID lock file
398 if ( $handle === false ) {
399 throw new RuntimeException( "Could not open '{$path}'." );
400 }
401 if ( !flock( $handle, LOCK_EX ) ) {
402 fclose( $handle );
403 throw new RuntimeException( "Could not acquire '{$path}'." );
404 }
405 // Fetch the counter value and increment it...
406 rewind( $handle );
407 $counter = floor( (float)trim( fgets( $handle ) ) ) + $count; // fetch as float
408 // Write back the new counter value
409 ftruncate( $handle, 0 );
410 rewind( $handle );
411 fwrite( $handle, fmod( $counter, 2 ** 48 ) ); // warp-around as needed
412 fflush( $handle );
413 // Release the UID lock file
414 flock( $handle, LOCK_UN );
415 }
416
417 $ids = [];
418 $divisor = 2 ** $bits;
419 $currentId = floor( $counter - $count ); // pre-increment counter value
420 for ( $i = 0; $i < $count; ++$i ) {
421 $ids[] = fmod( ++$currentId, $divisor );
422 }
423
424 return $ids;
425 }
426
444 protected function getTimeAndDelay( $lockFile, $clockSeqSize, $counterSize, $offsetSize ) {
445 // Get the UID lock file handle
446 if ( isset( $this->fileHandles[$lockFile] ) ) {
447 $handle = $this->fileHandles[$lockFile];
448 } else {
449 $handle = fopen( $this->$lockFile, 'cb+' );
450 $this->fileHandles[$lockFile] = $handle ?: null; // cache
451 }
452 // Acquire the UID lock file
453 if ( $handle === false ) {
454 throw new RuntimeException( "Could not open '{$this->$lockFile}'." );
455 }
456 if ( !flock( $handle, LOCK_EX ) ) {
457 fclose( $handle );
458 throw new RuntimeException( "Could not acquire '{$this->$lockFile}'." );
459 }
460
461 // The formatters that use this method expect a timestamp with millisecond
462 // precision and a counter upto a certain size. When more IDs than the counter
463 // size are generated during the same timestamp, an exception is thrown as we
464 // cannot increment further, because the formatted ID would not have enough
465 // bits to fit the counter.
466 //
467 // To orchestrate this between independant PHP processes on the same hosts,
468 // we must have a common sense of time so that we only have to maintain
469 // a single counter in a single lock file.
470 //
471 // Given that:
472 // * The system clock can be observed via time(), without milliseconds.
473 // * Some other clock can be observed via microtime(), which also offers
474 // millisecond precision.
475 // * microtime() drifts in-process further and further away from the system
476 // clock the longer the longer the process runs for.
477 // For example, on 2018-10-03 an HHVM 3.18 JobQueue process at WMF,
478 // that ran for 9 min 55 sec, drifted 7 seconds.
479 // The drift is immediate for processes running while the system clock changes.
480 // time() does not have this problem. See https://bugs.php.net/bug.php?id=42659.
481 //
482 // We have two choices:
483 //
484 // 1. Use microtime() with the following caveats:
485 // - The last stored time may be in the future, or our current time
486 // may be in the past, in which case we'll frequently enter the slow
487 // timeWaitUntil() method to try and "sync" the current process with
488 // the previous process. We mustn't block for long though, max 10ms?
489 // - For any drift above 10ms, we pretend that the clock went backwards,
490 // and treat it the same way as after an NTP sync, by incrementing clock
491 // sequence instead. Given this rolls over automatically and silently
492 // and is meant to be rare, this is essentially sacrifices a reasonable
493 // guarantee of uniqueness.
494 // - For long running processes (e.g. longer than a few seconds) the drift
495 // can easily be more than 2 seconds. Because we only have a single lock
496 // file and don't want to keep too many counters and deal with clearing
497 // those, we fatal the user and refuse to make an ID. (T94522)
498 // 2. Use time() and expand the counter by 1000x and use the first digits
499 // as if they are the millisecond fraction of the timestamp.
500 // Known caveats or perf impact: None.
501 //
502 // We choose the latter.
503 $msecCounterSize = $counterSize * 1000;
504
505 rewind( $handle );
506 // Format of lock file contents:
507 // "<clk seq> <sec> <msec counter> <rand offset>"
508 $data = explode( ' ', fgets( $handle ) );
509
510 if ( count( $data ) === 4 ) {
511 // The UID lock file was already initialized
512 $clkSeq = (int)$data[0] % $clockSeqSize;
513 $prevSec = (int)$data[1];
514 // Counter for UIDs with the same timestamp,
515 $msecCounter = 0;
516 $randOffset = (int)$data[3] % $counterSize;
517
518 // If the system clock moved backwards by an NTP sync,
519 // or if the last writer process had its clock drift ahead,
520 // Try to catch up if the gap is small, so that we can keep a single
521 // monotonic logic file.
522 $sec = $this->timeWaitUntil( $prevSec );
523 if ( $sec === false ) {
524 // Gap is too big. Looks like the clock got moved back significantly.
525 // Start a new clock sequence, and re-randomize the extra offset,
526 // which is useful for UIDs that do not include the clock sequence number.
527 $clkSeq = ( $clkSeq + 1 ) % $clockSeqSize;
528 $sec = time();
529 $randOffset = mt_rand( 0, $offsetSize - 1 );
530 trigger_error( "Clock was set back; sequence number incremented." );
531 } elseif ( $sec === $prevSec ) {
532 // Sanity check, only keep remainder if a previous writer wrote
533 // something here that we don't accept.
534 $msecCounter = (int)$data[2] % $msecCounterSize;
535 // Bump the counter if the time has not changed yet
536 if ( ++$msecCounter >= $msecCounterSize ) {
537 // More IDs generated with the same time than counterSize can accomodate
538 flock( $handle, LOCK_UN );
539 throw new RuntimeException( "Counter overflow for timestamp value." );
540 }
541 }
542 } else {
543 // Initialize UID lock file information
544 $clkSeq = mt_rand( 0, $clockSeqSize - 1 );
545 $sec = time();
546 $msecCounter = 0;
547 $randOffset = mt_rand( 0, $offsetSize - 1 );
548 }
549
550 // Update and release the UID lock file
551 ftruncate( $handle, 0 );
552 rewind( $handle );
553 fwrite( $handle, "{$clkSeq} {$sec} {$msecCounter} {$randOffset}" );
554 fflush( $handle );
555 flock( $handle, LOCK_UN );
556
557 // Split msecCounter back into msec and counter
558 $msec = (int)( $msecCounter / 1000 );
559 $counter = $msecCounter % 1000;
560
561 return [
562 'time' => [ $sec, $msec ],
563 'counter' => $counter,
564 'clkSeq' => $clkSeq,
565 'offset' => $randOffset,
566 'offsetCounter' => $counter + $randOffset,
567 ];
568 }
569
577 protected function timeWaitUntil( $time ) {
578 $start = microtime( true );
579 do {
580 $ct = time();
581 // https://www.php.net/manual/en/language.operators.comparison.php
582 if ( $ct >= $time ) {
583 // current time is higher than or equal to than $time
584 return $ct;
585 }
586 } while ( ( microtime( true ) - $start ) <= 0.010 ); // up to 10ms
587
588 return false;
589 }
590
596 protected function millisecondsSinceEpochBinary( array $time ) {
597 list( $sec, $msec ) = $time;
598 $ts = 1000 * $sec + $msec;
599 if ( $ts > 2 ** 52 ) {
600 throw new RuntimeException( __METHOD__ .
601 ': sorry, this function doesn\'t work after the year 144680' );
602 }
603
604 return substr( \Wikimedia\base_convert( $ts, 10, 2, 46 ), -46 );
605 }
606
613 protected function intervalsSinceGregorianBinary( array $time, $delta = 0 ) {
614 list( $sec, $msec ) = $time;
615 $offset = '122192928000000000';
616 if ( PHP_INT_SIZE >= 8 ) { // 64 bit integers
617 $ts = ( 1000 * $sec + $msec ) * 10000 + (int)$offset + $delta;
618 $id_bin = str_pad( decbin( $ts % ( 2 ** 60 ) ), 60, '0', STR_PAD_LEFT );
619 } elseif ( extension_loaded( 'gmp' ) ) {
620 $ts = gmp_add( gmp_mul( (string)$sec, '1000' ), (string)$msec ); // ms
621 $ts = gmp_add( gmp_mul( $ts, '10000' ), $offset ); // 100ns intervals
622 $ts = gmp_add( $ts, (string)$delta );
623 $ts = gmp_mod( $ts, gmp_pow( '2', '60' ) ); // wrap around
624 $id_bin = str_pad( gmp_strval( $ts, 2 ), 60, '0', STR_PAD_LEFT );
625 } elseif ( extension_loaded( 'bcmath' ) ) {
626 $ts = bcadd( bcmul( $sec, 1000 ), $msec ); // ms
627 $ts = bcadd( bcmul( $ts, 10000 ), $offset ); // 100ns intervals
628 $ts = bcadd( $ts, $delta );
629 $ts = bcmod( $ts, bcpow( 2, 60 ) ); // wrap around
630 $id_bin = \Wikimedia\base_convert( $ts, 10, 2, 60 );
631 } else {
632 throw new RuntimeException( 'bcmath or gmp extension required for 32 bit machines.' );
633 }
634 return $id_bin;
635 }
636
640 private function load() {
641 if ( $this->loaded ) {
642 return; // already called
643 }
644
645 $this->loaded = true;
646
647 $nodeId = '';
648 if ( is_file( $this->nodeIdFile ) ) {
649 $nodeId = file_get_contents( $this->nodeIdFile );
650 }
651 // Try to get some ID that uniquely identifies this machine (RFC 4122)...
652 if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
653 AtEase::suppressWarnings();
654 if ( PHP_OS_FAMILY === 'Windows' ) {
655 // https://technet.microsoft.com/en-us/library/bb490913.aspx
656 $csv = trim( ( $this->shellCallback )( 'getmac /NH /FO CSV' ) );
657 $line = substr( $csv, 0, strcspn( $csv, "\n" ) );
658 $info = str_getcsv( $line );
659 $nodeId = isset( $info[0] ) ? str_replace( '-', '', $info[0] ) : '';
660 } elseif ( is_executable( '/sbin/ifconfig' ) ) { // Linux/BSD/Solaris/OS X
661 // See https://linux.die.net/man/8/ifconfig
662 $m = [];
663 preg_match( '/\s([0-9a-f]{2}(?::[0-9a-f]{2}){5})\s/',
664 ( $this->shellCallback )( '/sbin/ifconfig -a' ), $m );
665 $nodeId = isset( $m[1] ) ? str_replace( ':', '', $m[1] ) : '';
666 }
667 AtEase::restoreWarnings();
668 if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
669 $nodeId = bin2hex( random_bytes( 12 / 2 ) );
670 $nodeId[1] = dechex( hexdec( $nodeId[1] ) | 0x1 ); // set multicast bit
671 }
672 file_put_contents( $this->nodeIdFile, $nodeId ); // cache
673 }
674 $this->nodeId32 = \Wikimedia\base_convert( substr( sha1( $nodeId ), 0, 8 ), 16, 2, 32 );
675 $this->nodeId48 = \Wikimedia\base_convert( $nodeId, 16, 2, 48 );
676 }
677
681 private function getNodeId32() {
682 $this->load();
683
684 return $this->nodeId32;
685 }
686
690 private function getNodeId48() {
691 $this->load();
692
693 return $this->nodeId48;
694 }
695
707 private function deleteCacheFiles() {
708 foreach ( $this->fileHandles as $path => $handle ) {
709 if ( $handle !== null ) {
710 fclose( $handle );
711 }
712 if ( is_file( $path ) ) {
713 unlink( $path );
714 }
715 unset( $this->fileHandles[$path] );
716 }
717 if ( is_file( $this->nodeIdFile ) ) {
718 unlink( $this->nodeIdFile );
719 }
720 }
721
734 public function unitTestTearDown() {
735 $this->deleteCacheFiles();
736 }
737
738 public function __destruct() {
739 array_map( 'fclose', array_filter( $this->fileHandles ) );
740 }
741}
Class representing a cache/ephemeral data store.
Definition BagOStuff.php:71
incrWithInit( $key, $exptime, $value=1, $init=null, $flags=0)
Increase the value of the given key (no TTL change) if it exists or create it otherwise.
A BagOStuff object with no objects in it.
Class for getting statistically unique IDs without a central coordinator.
newRawUUIDv1()
Return an RFC4122 compliant v1 UUID.
newSequentialPerNodeID( $bucket, $bits=48, $flags=0)
Return an ID that is sequential only for this node and bucket.
newUUIDv4()
Return an RFC4122 compliant v4 UUID.
newTimestampedUID88( $base=10)
Get a statistically unique 88-bit unsigned integer ID string.
getSequentialPerNodeIDs( $bucket, $bits, $count, $flags)
Return IDs that are sequential only for this node and bucket.
newRawUUIDv4()
Return an RFC4122 compliant v4 UUID.
const FILE_PREFIX
Avoid using CLASS so namespace separators aren't interpreted as path components on Windows (T259693)
unitTestTearDown()
Cleanup resources when tearing down after a unit test (T46850)
string $tmpDir
Temporary directory.
string $nodeId32
Node ID in binary (32 bits)
__construct( $tempDirectory, BagOStuff $srvCache, callable $shellCallback)
string $nodeId48
Node ID in binary (48 bits)
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.
BagOStuff $srvCache
Server-local persistent cache instance.
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.
load()
Load the node ID information.
newSequentialPerNodeIDs( $bucket, $bits, $count, $flags=0)
Return IDs that are sequential only for this node and bucket.
intervalsSinceGregorianBinary(array $time, $delta=0)
deleteCacheFiles()
Delete all cache files that have been created (T46850)
newTimestampedUID128( $base=10)
Get a statistically unique 128-bit unsigned integer ID string.
$line
Definition mcc.php:119
$cache
Definition mcc.php:33
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...