MediaWiki  master
UIDGenerator.php
Go to the documentation of this file.
1 <?php
24 
31 class UIDGenerator {
33  public const QUICK_RAND = 0; // b/c
35  public const QUICK_VOLATILE = GlobalIdGenerator::QUICK_VOLATILE;
36 
52  public static function newTimestampedUID88( $base = 10 ) {
53  $gen = MediaWikiServices::getInstance()->getGlobalIdGenerator();
54 
55  return $gen->newTimestampedUID88( $base );
56  }
57 
72  public static function newTimestampedUID128( $base = 10 ) {
73  $gen = MediaWikiServices::getInstance()->getGlobalIdGenerator();
74 
75  return $gen->newTimestampedUID128( $base );
76  }
77 
85  public static function newUUIDv1() {
86  $gen = MediaWikiServices::getInstance()->getGlobalIdGenerator();
87 
88  return $gen->newUUIDv1();
89  }
90 
98  public static function newRawUUIDv1() {
99  $gen = MediaWikiServices::getInstance()->getGlobalIdGenerator();
100 
101  return $gen->newRawUUIDv1();
102  }
103 
111  public static function getTimestampFromUUIDv1( string $uuid, int $format = TS_MW ) {
112  $gen = MediaWikiServices::getInstance()->getGlobalIdGenerator();
113 
114  return $gen->getTimestampFromUUIDv1( $uuid, $format );
115  }
116 
124  public static function newUUIDv4( $flags = 0 ) {
125  $gen = MediaWikiServices::getInstance()->getGlobalIdGenerator();
126 
127  return $gen->newUUIDv4();
128  }
129 
137  public static function newRawUUIDv4( $flags = 0 ) {
138  $gen = MediaWikiServices::getInstance()->getGlobalIdGenerator();
139 
140  return $gen->newRawUUIDv4();
141  }
142 
155  public static function newSequentialPerNodeID( $bucket, $bits = 48, $flags = 0 ) {
156  $gen = MediaWikiServices::getInstance()->getGlobalIdGenerator();
157 
158  return $gen->newSequentialPerNodeID( $bucket, $bits, $flags );
159  }
160 
172  public static function newSequentialPerNodeIDs( $bucket, $bits, $count, $flags = 0 ) {
173  $gen = MediaWikiServices::getInstance()->getGlobalIdGenerator();
174 
175  return $gen->newSequentialPerNodeIDs( $bucket, $bits, $count, $flags );
176  }
177 }
UIDGenerator\newTimestampedUID128
static newTimestampedUID128( $base=10)
Get a statistically unique 128-bit unsigned integer ID string.
Definition: UIDGenerator.php:72
Wikimedia\UUID\GlobalIdGenerator
Class for getting statistically unique IDs without a central coordinator.
Definition: GlobalIdGenerator.php:36
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:160
UIDGenerator\newUUIDv1
static newUUIDv1()
Return an RFC4122 compliant v1 UUID.
Definition: UIDGenerator.php:85
UIDGenerator
Class for getting statistically unique IDs.
Definition: UIDGenerator.php:31
$base
$base
Definition: generateLocalAutoload.php:11
UIDGenerator\newRawUUIDv4
static newRawUUIDv4( $flags=0)
Return an RFC4122 compliant v4 UUID.
Definition: UIDGenerator.php:137
UIDGenerator\newSequentialPerNodeID
static newSequentialPerNodeID( $bucket, $bits=48, $flags=0)
Return an ID that is sequential only for this node and bucket.
Definition: UIDGenerator.php:155
UIDGenerator\newTimestampedUID88
static newTimestampedUID88( $base=10)
Get a statistically unique 88-bit unsigned integer ID string.
Definition: UIDGenerator.php:52
UIDGenerator\newUUIDv4
static newUUIDv4( $flags=0)
Return an RFC4122 compliant v4 UUID.
Definition: UIDGenerator.php:124
UIDGenerator\newRawUUIDv1
static newRawUUIDv1()
Return an RFC4122 compliant v1 UUID.
Definition: UIDGenerator.php:98
UIDGenerator\newSequentialPerNodeIDs
static newSequentialPerNodeIDs( $bucket, $bits, $count, $flags=0)
Return IDs that are sequential only for this node and bucket.
Definition: UIDGenerator.php:172
UIDGenerator\getTimestampFromUUIDv1
static getTimestampFromUUIDv1(string $uuid, int $format=TS_MW)
Get timestamp in a specified format from UUIDv1.
Definition: UIDGenerator.php:111